我是AngularJS的新手,我试图创建一个身份验证服务,但我收到了这个错误。
Error: [$injector:modulerr] Failed to instantiate module flujoDeCaja due to:
[$injector:modulerr] Failed to instantiate module auth due to:
[$injector:nomod] Module 'auth' 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.
这是我的代码:
Service.js
'use strict';
var mod = angular.module('auth',['restangular']);
mod.service('AuthService', ['', function(){
var userIsAuthenticated = false;
this.setUserAuthenticated = function(value){
userIsAuthenticated = value;
};
this.getUserAuthenticated = function(){
return userIsAuthenticated;
});
}]);
App.js
var angularModule = angular.module('flujoDeCaja', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'restangular',
'auth'
]);
的index.html
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/restangular/dist/restangular.js"></script>
<script src="scripts/services/services.js"></script>
<script src="scripts/app.js"></script>
我做错了什么?
提前谢谢你:)
答案 0 :(得分:1)
纠正了我认为错误的一点。
mod.service('AuthService', [function(){
var userIsAuthenticated = false;
this.setUserAuthenticated = function(value){
userIsAuthenticated = value;
};
this.getUserAuthenticated = function(){
return userIsAuthenticated;
};
}]);