0

我怎样才能开始使用这个模块: http: //gregpike.net/demos/angular-local-storage/demo/demo.html 我有一个控制器:

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

});

我注射了

localStorageService

如示例所示,但自然没有任何作用。我该如何解决?谢谢。

4

2 回答 2

0

首先,从页面链接脚本:

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

其次,您将模块添加到模块依赖项数组中(我猜这就是您错过的):

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

然后,您可以像以前一样在组件中注入和使用localStorageService


也就是说,我会添加一个步骤 0:阅读此自述文件:)

于 2015-10-18T17:45:44.860 回答
0

我推荐你这个https://github.com/gsklee/ngStorage也使用这种语法来不破坏你缩小时

app.controller('FormController', ["$scope", "otherProvider",function ($scope, otherProvider) {
//in this way angular know what to inject
}]);
于 2015-10-18T17:45:57.987 回答