angularjs - Uncaught Error: No module: LocalStorageModule -
i trying work on angularjs project local storage. making todo list application , storing each todo note using angular-local-storage
. have made localstorageservice
used in controller. have injected service dependency in app.js keep getting blank page , console error: uncaught error: no module: localstoragemodule
. there wrong syntax??... or using service incorrectly?
app.coffee
@angtut = angular.module("angtut", ['localstoragemodule']); @angtut.config(["$routeprovider", ($routeprovider) -> $routerprovider = $routeprovider; $routeprovider.when("/", templateurl: "views/pages/welcome.html" controller: "pagescontroller" ); $routeprovider.when("/add", templateurl: "views/todos/add.html" controller: "todoscontroller" ); $routeprovider.otherwise( redirectto: "/" ); ])
todo_controller.coffee
"use strict" @angtut.controller('todoscontroller', ( $scope todoservice ) -> $scope.save = -> todoservice.add($scope.note) $scope.list() $scope.clear = -> todoservice.clear() $scope.list() $scope.list = -> $scope.notes = [] storednotes = todoservice.get(true) if storednotes? = 0 while < storednotes.length $scope.notes.push storednotes[i] i++ )
todo_service.coffee
'use strict' @angtut.service('todoservice', ( localstorageservice ) -> addfn = (data) -> existingvalue = getfn(); if(existingvalue isnt null) newdata = existingvalue + ',' + data localstorageservice.add('somestoragekey', newdata) else localstorageservice.add('somestoragekey', data) return data getfn = (returnasarray) -> storednotes = localstorageservice.get('somestoragekey') if storednotes? , returnasarray return storednotes.split(',') else return storednotes clearfn = -> localstorageservice.clearall() add: addfn get: getfn clear: clearfn )
i has how referenced dependency in bower.json
. name of component isn't project name on github. it's possible bower component renamed i'm not sure that. if try searching component project name;
bower search angular-local-storage no results.
i believe name of component intend use 'angular-localstorage'.
☺ bower search angular-localstorage ruby-2.0.0-p247 search results: angular-localstorage git://github.com/grevory/angular-local-storage.git
if case, make necessary changes make sure you're referencing right in 'bower.json' file.
e.g
"dependencies": { ... "angular-localstorage": "*" }
don't forget name right in view well.
note actual javascript file still 'angular-local-storage.js'
e.g.
<script src="components/angular-localstorage/angular-local-storage.js"></script>