angularjssessionstorageangularjs-injectorng-storage

Could not inject 'ngStorage' after including ngStorage file


I've included this line to use ngStorage

<script src="js/angularjs/ngStorage.min.js"></script>

and injected it to my controller named bookController like I always do

.controller('bookController', ['$scope', 'bookService', '$location', '$sessionStorage', function($scope, bookService, $location, $sessionStorage)

Why am I still getting injector error like this?

angular.min.js:118 Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/$injector/unpr?p0=<div ng-view="" class="ng-scope">essionStorageProvider%20%3C-%20%24sessionStorage%20%3C-%20bookController
at http://localhost/cm0665/js/angularjs/angular.min.js:6:412
at http://localhost/cm0665/js/angularjs/angular.min.js:43:174
at Object.d [as get] (http://localhost/cm0665/js/angularjs/angular.min.js:40:432)
at http://localhost/cm0665/js/angularjs/angular.min.js:43:236
at d (http://localhost/cm0665/js/angularjs/angular.min.js:40:432)
at e (http://localhost/cm0665/js/angularjs/angular.min.js:41:158)
at Object.instantiate (http://localhost/cm0665/js/angularjs/angular.min.js:42:24)
at http://localhost/cm0665/js/angularjs/angular.min.js:90:32
at Object.link (http://localhost/cm0665/js/angularjs/angular-route.min.js:7:274)
at http://localhost/cm0665/js/angularjs/angular.min.js:16:71

You help is much appreciated!


Solution

  • You need to inject the ngStorage module into your module.

    Then you can use $sessionStorage in your controller.