Uncaught Error: [$injector:unpr] Unknown provider: $localstorageProvider <- $localstorage
12,561
Solution 1
Change
$localstorage
to
$window.localStorage //S is capitalized
And inject the $window
dependancy in your run function.
Solution 2
you are possibly missing a dependency! have a look at e.g. https://github.com/gsklee/ngStorage.
include it into your project and require the ngStorage-module like so:
angular.module('starter', ['ngStorage', 'ionic', 'starter.controllers','ngCordova'])
.run(function($ionicPlatform, $localStorage , $cordovaPush) {
$ionicPlatform.ready(function() {
console.log($localStorage); // edit: capital S
})
})
Author by
Amy Glenn
Updated on June 15, 2022Comments
-
Amy Glenn over 1 year
Was using ionic, in my app.js I do
angular.module('starter', ['ionic', 'starter.controllers','ngCordova']) .run(function($ionicPlatform, $localStorage , $cordovaPush) { $ionicPlatform.ready(function() { console.log($localStorage); }) })
But I got error of
Uncaught Error: [$injector:unpr] Unknown provider: $localstorageProvider <- $localstorage
Any thought? so strange..
-
sp00m almost 8 yearsYou're injecting $localStorage but the error message says $localstorage. You're sure about the case?
-
Tarun Dugar almost 8 yearsModified my answer. Rectified a simple mistake. It should work now.
-
-
Jason Spence about 7 yearsThis solved my issue. I was missing 'ngStorage' in my module.