Hi i have been trying to use foreach on the returned response which not seems to be working. Can anybody tell me what am doing wrong, I have also tried with promises but not seems to be working.
$scope.signuser=Login.query({email:$scope.user.signemail});
Response in console:
[$promise: d, $resolved: false]
0: e
$promise: d$$state: Objectpending: undefinedprocessScheduled: falsestatus: value: Array[1]
I have tried using $scope.signuser[0]
which seems to be not working as well as foreach.Also tried with $Promises. What am doing wrong? I need to access the 0th element of the variable. Any help would be appreciated Thanks in advance.
It looks like you are doing this all in your controller, so try this following pattern for now. You should be able to see what is going on here, basically we're placing a $watch
on $scope.signuser
which will keep track of it's value so we can log it out after our promise has resolved.
$scope.signuser = null // for now - until promise is resolved
Login.query({ email: $scope.user.signemail }).then(function(response) {
$scope.signuser = response.data[0];
});
$scope.$watch('signuser', function(newValue, oldValue) {
console.log(newValue);
});