I noticed that angular recently removed the feature to automatically unwrap 
promises when binding values from the $scope to templates. However, it 
seems that the "promises" returned from the $resource service do seem to 
unwrap automatically. I was having difficulty tracking down the mechanism 
used which makes that work, but I'm curious whether that behavior will also 
be deprecated or whether it's ok to rely on it.

As an example, this code seems to work for things returned by $resource:

$scope.things = Model.getThings({ property: '123' });

However, this seems to be the way to do it with promises now:

Model.getThings({ property: '123' }).$promise.then((things) => {
    $scope.things = things;
});

Accessing .$promise directly feels really weird though. I also don't 
understand why $resource returns an array containing $promise and $resolved 
instead of just returning the promise (maybe it deals with getting the 
automatic unwrapping behavior?). I tried returning a similar structure from 
one of my own methods and it did not get automatically unwrapped...

Can anyone help explain the thinking around this and how we should use it?

Thanks for the help,

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to