angularjsangularjs-module

How to use custom module AngularJs


how can I start to use this module: http://gregpike.net/demos/angular-local-storage/demo/demo.html I have a controller:

app.controller('FormController', function ($scope, localStorageService) {

});

And I injected

localStorageService

as shown in example, but naturally nothing work. How can I fix it? Thanks.


Solution

  • First, you link the script from your page:

    <script src=".../angular-local-storage.min.js"></script>
    

    Second, you add the module to the module dependencies array (I guess that's what you missed):

    angular.module('myApp', [..., 'LocalStorageModule', ...])
    

    Then you can inject and use localStorageService in your components, as you did.


    That said, I would add a step 0 : Read this Readme :)