I am trying to get a callback from the angular service but the callback function does not work.
Here is My controller code:-
$scope.uu = "hello" // this i just make for test
$scope.login = function(user){
//console.log(user)
AuthenticationService.Login(user.username,user.password).success(function(data){
console.log(data);
$scope.uu = data;
})
}
My service code is:-
mainApp.service('AuthenticationService',function($http,$cookieStore,$rootScope){
var service = {};
service.Login = function (username, password, callback) {
$http({
method: "POST",
//headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: 'users/authenticate',
data: {email: username,password:password}
})
.success(callback);
};
return service;
});
Neither I get response in console. Neither the scope is changed. I have referred to this question but the answer is not working for me. $http POST response from service to controller