0
login_app.factory('login_service', function ($http) {
return {
login: function (user,pass) {
//return the promise directly.
return $http({
url:"/service/login",
method:"POST",
data:JSON.stringify({username:user,password:pass})
}).success(function (data, status, headers, config) {
// assign $scope.persons here
// as promise is resolved here
localStorage.setItem("auth_token",headers("X-Auth-Token"));
window.location = "/layout/dashboard"
}).error(function (data, status, headers, config) {
// If I have a custom alert box, should I display it from
// or I should use a directive for bootstrap alert-box.
// But what should I do here so that Alertbox knows it is
});
}
}
});