gpt4 book ai didi

javascript - 模块 'ngStorage' 不可用

转载 作者:行者123 更新时间:2023-11-30 15:30:41 27 4
gpt4 key购买 nike

所以,我是 Angular 的新手,我正在构建一个将数据保存在浏览器的 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/ $注入(inject)器/模块?

我已经阅读了很多论坛,并且已经研究了所有我能找到的答案,但仍然没有运气。任何人都可以看到我遗漏的东西吗?

这是我的索引脚本:

<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 ) {

非常感谢任何帮助!谢谢

最佳答案

只需将您的 ng-storage 脚本标签移动到 angular 下方。这取决于 Angular ,所以它应该在那之后:

<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>

关于javascript - 模块 'ngStorage' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42284938/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com