We must set the inejctor for 'localStorageService' instead of 'LocalStorageModule'
So, the code should look like this:
angular .module('MyModule') .controller('MyController', ['$scope', '$stateParams','$location' , '$http' // instead of this // ,'LocalStorageModule', // use this ,'localStorageService', function($scope, $stateParams, $location, $http, localStorageService) { //localStorageService.add('test', 'val'); localStorageService.set('test', 'val'); }]);
And when we initialize the module, we must enable the local storage module
angular .module('MyModule', [ 'LocalStorageModule', ... ])
And also as described here:
we must use .set()
// To add to local storage localStorageService.set('localStorageKey','Add this!');
Radim Köhler
source share