1

Can we Inject 'ui.grid' at controller level not at Module level.

something like this.

.controller('gridController', ['ui.grid', function ($scope) {


    }])

Error: [$injector:unpr] Unknown provider: ui.gridProvider <- ui.grid <- gridController

Shakeer Hussain
  • 2,230
  • 7
  • 29
  • 52

1 Answers1

1

Short answer is No.

ui.grid is a module so it has to be at the module level.

In controllers you can inject factories, services etc which make a module.

bhantol
  • 9,368
  • 7
  • 44
  • 81
  • I have below error if i add at module level. Error: [$injector:nomod] Module 'ui.grid' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. – Shakeer Hussain Oct 05 '16 at 21:05
  • You may not have ui-grid.js Javascript code to your html/(index.html). Check to make sure it is after angularjs. – bhantol Oct 05 '16 at 21:07
  • In the browser check Network tab to ensure if all the relevant Java scripts were downloaded. Ensure proper sequence. angular.js, ui-grid.js, your app.js which defined module as per http://ui-grid.info/docs/#/tutorial/101_intro – bhantol Oct 05 '16 at 21:20
  • Anyway that is a different question however if you can create a plnkr I or someone can take a quick look. Its should be a easy fix. – bhantol Oct 05 '16 at 21:21
  • I am not using ui.grid in index.html page. Do i need to add reference even though not using? – Shakeer Hussain Oct 05 '16 at 21:29
  • Yes. If you have in module. – bhantol Oct 05 '16 at 21:33