I’m working on the login portion of my app but my verification service doesn’t seem to be working. I’m checking inputs for users email and password from the html page and using this ctrl with the button click
app.controller('Controller', ['$scope', '$ionicPopup', '$state', function($scope, $location, LoginService, $state, $ionicPopup, $timeout){
$scope.controller ={};
$scope.controller.login = function() {
LoginService.loginUser($scope.email, $scope.password).success(function () {
$state.go('createAccount');
}).error(function () {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
console.log("Username: " + $scope.email + "Passowrd: " + $scope.password);
};
}]);
My service is
.service('LoginService', function() {
return {
loginUser: function(name, pw) {
var deferred = defer();
var promise = deferred.promise;
if (name == 'user' && pw == 'secret') {
deferred.resolve('Welcome ' + name + '!');
} else {
deferred.reject('Wrong credentials.');
}
promise.success = function(fn) {
promise.then(fn);
return promise;
};
promise.error = function(fn) {
promise.then(null, fn);
return promise;
};
return promise;
}
}
});
and my state is just
.state('login', {
url: '/Login.html',
templateUrl: 'views/login.html'
})
I’ve gotten this service to work before but when I integrated it into my app it suddenly stopped functioning. I’ve been trying to fix this for a while now so any help would be greately appreciated.