模块'ngStorage'不可用

问题描述:

所以,我是新角度,我正在构建一个应用程序,将数据保存在我的浏览器的localStorage中。我试图用ngStorage为,但我得到了以下错误:模块'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) { 

任何帮助将是非常aprecciated !谢谢

只需将您的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> 
+0

谢谢亚瑟。这解决了问题! – codeFleck