I noticed that I can use the $http provider in this way:
Auth.login(userdetails).then(function(response){
//...
}
app.service('Auth', ['$http', function ($http) {
AuthService.login = function (credentials) {
return $http.
post('getauth.php', credentials).
then(function (res) {
//create the session, etc.
});
}]);
Notice the return statement in front of http and the use of then() on http instead of success().
Why does this work? Are there any downsides?