I'm trying to add a login module to my AngularJS app. When I try to call UserService from the authenticationService, it's showing as undefined. What am I missing here, why is UserService coming up as undefined?
var authenticationService = angular.module('authenticationService', []);
authenticationService.factory('authenticationSvc', ['$http', '$cookieStore', '$rootScope', '$timeout', 'UserService',
function AuthenticationService($scope, $http, $cookieStore, $rootScope, $timeout, UserService) {
var service = {};
service.Login = Login;
service.SetCredentials = SetCredentials;
service.ClearCredentials = ClearCredentials;
return service;
function Login(username, password, callback) {
var response;
UserService.GetByUsername(username) //UserService is unidefined!!!
.then(function (user) {
if (user !== null && user.password === password) {
response = { success: true };
} else {
response = { success: false, message: 'Username or password is incorrect' };
}
callback(response);
});
}