所以,我是角色的新手,我正在构建一个应用程序,可以将数据保存在浏览器的localStorage中。我尝试使用ngStorage,但是我收到以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myApp.funcionarios due to:
Error: [$injector:modulerr] Failed to instantiate module ngStorage due to:
Error: [$injector:nomod] Module 'ngStorage' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.11/$injector/nomod?p0=ngStorage
at http://localhost:8000/bower_components/angular/angular.js:68:12
at http://localhost:8000/bower_components/angular/angular.js:2133:17
at ensure (http://localhost:8000/bower_components/angular/angular.js:2057:38)
at module (http://localhost:8000/bower_components/angular/angular.js:2131:14)
at http://localhost:8000/bower_components/angular/angular.js:4669:22
at forEach (http://localhost:8000/bower_components/angular/angular.js:325:20)
at loadModules (http://localhost:8000/bower_components/angular/angular.js:4653:5)
at http://localhost:8000/bower_components/angular/angular.js:4670:40
at forEach (http://localhost:8000/bower_components/angular/angular.js:325:20)
at loadModules (http://localhost:8000/bower_components/angular/angular.js:4653:5)
http://errors.angularjs.org/1.5.11/ $注射器/ modulerr?
我已经阅读了很多foruns,我已经找到了我能找到的所有答案,但仍然没有运气。任何人都可以看到我失踪的东西?
这是我的索引脚本:
<script src="bower_components/ngstorage/ngStorage.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
<script src="funcionarios/funcionarios.js"></script>
<script src="app.js"></script>
我的app.js:
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', ['myApp.funcionarios', 'ngRoute', 'ngStorage' ])
.config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({redirectTo: '/funcionarios'});
}]);
这是myApp.funcionarios:
'use strict';
angular.module('myApp.funcionarios', ['ngRoute', 'ngStorage'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/funcionarios', {
templateUrl: 'funcionarios/funcionarios.html',
controller: 'FuncionariosCtrl'
});
}])
.controller('FuncionariosCtrl', ['$scope', '$localStorage', '$sessionStorage', function( $scope, $localStorage, $sessionStorage ) {
任何帮助都会得到很好的帮助!感谢
答案 0 :(得分:2)
只需将ng-storage
脚本标记移动到角度以下即可。它取决于角度所以它应该在那之后:
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/ngstorage/ngStorage.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>
<script src="funcionarios/funcionarios.js"></script>
<script src="app.js"></script>