I have a simple auth factory in angular with the following codes
.factory 'User',($window,$rootScope,Restangular)->
{
auth: (username,password)->
Restangular.all 'auth/login/'
.post {username:username,password:password}
.then (response)->
return response
,(response) ->
return response
.....
and i am calling that from my controller using
$scope.login = ()->
$scope.running = 1
console.log User.auth $scope.username,$scope.password
$scope.running = 0
return
The problem is that i need to show the errors on login if any and set them in controller but restangular being async, i am not sure how to do to same. As you can see from the first code segment that i tried to return the values but even they don't seem to work.
How can i get the reponse codes from the server in scope using Restangular