Reputation: 1324
Im new in AngularJS and im trying to create an authentication service but I'm getting this error.
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.
Here is my code:
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>
What I'm doing wrong?
Thank you in advance :)
Upvotes: 0
Views: 6231
Reputation: 19748
Corrected the bit I believe is wrong.
mod.service('AuthService', [function(){
var userIsAuthenticated = false;
this.setUserAuthenticated = function(value){
userIsAuthenticated = value;
};
this.getUserAuthenticated = function(){
return userIsAuthenticated;
};
}]);
Upvotes: 1