gsklee / ngStorage

localStorage and sessionStorage done right for AngularJS.
MIT License
2.33k stars 461 forks source link

getting an injector error #218

Closed end-user closed 8 years ago

end-user commented 8 years ago

I'm getting a Error: [$injector:unpr] Unknown provider: ngStorageProvider <- ngStorage

I've installed this with bower install ngstorage, and it appears in my list of bower dependencies.

I've injected it as I have with other modules:

angular.module('app') .controller('ExpertViewController', ['Parent', 'Child', 'LookupService', 'ngStorage', function($scope, Parent, Child, LookupService, $sessionStorage) {

However, when I try use it in the body of the controller function, I'm getting Error: [$injector:unpr] Unknown provider: ngStorageProvider <- ngStorage <- ExpertViewController

This seems like the right way to go, but I can't see why it's not working.

valeksiev commented 8 years ago

In the controller you should be injecting $localStorage or $sessionStorage - not ngStorage.

ngStorage should be added as dependency of your Angular app.

The following example should be working fine:

angular.module('app') .controller('ExpertViewController', ['Parent', 'Child', 'LookupService', '$sessionStorage', function($scope, Parent, Child, LookupService, $sessionStorage) {

egilkh commented 8 years ago

Example provided by @valeksiev should be working fine. Thanks!