Reputation: 183
In angularjs, I am trying to return get isInternal true or false value based on a promise function. But I am getting another promise (Promise {$$state: Object} $$state : Object status : 1 value : true)
$scope.isInternal = userInfo.getUser().then(function(user) {return user.internal;});
console.log($scope.isInternal);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
Upvotes: 0
Views: 393
Reputation: 663
here is a good tutorial on promises , three is a section there that specificly says why something like this :
var var = service.getAsyncData() ... won't work as expected
Upvotes: 0
Reputation: 487
You should try:
userInfo.getUser().then(function(user) {
$scope.isInternal = user.internal;
});
Upvotes: 3