4 ms·
Fyi promise unraveling has been deprecated after Angular 1.2. So it should be Group.query().then(function(groups){ $scope.groups = groups; })
by kclay 12y ago
Fyi promise unraveling has been deprecated after Angular 1.2. So it should be
Group.query().then(function(groups){
$scope.groups = groups;
})
- donmack 12y agoDo you have a link to any discussion on that? It looks like the docs still suggest the method used in the blog post: https://docs.angularjs.org/api/ngResource/service/$resource https://docs.angularjs.org/api/ngResource/service/$resource "It is important to realize that invoking a $resource object method immediately returns an empty reference [...] Once the data is returned from the server the existing reference is populated with the actual data. This is a useful trick since usually the resource is assigned to a model which is then rendered by the view. [...] This means that in most cases one never has to write a callback function for the action methods."
- bronson 12y agohttps://github.com/angular/angular.js/commit/fa6e411da26824a5bae55f37ce7dbb859653276d https://github.com/angular/angular.js/commit/fa6e411da26824a... https://github.com/angular/angular.js/commit/5dc35b527b3c99f6544b8cb52e93c6510d3ac577 https://github.com/angular/angular.js/commit/5dc35b527b3c99f... http://blog.angularjs.org/2013/12/angularjs-13-new-release-approaches.html http://blog.angularjs.org/2013/12/angularjs-13-new-release-a...
- donmack 12y agoThanks. Okay, that makes sense. The $resource usage described still works in version 1.2.19, with no promise unwrapping options set. I could be wrong, but I think it is because the $resource returns a reference to an empty object that has values copied into it when the call completes. The actual promise is a property named $promise on the returned object. Example: http://jsfiddle.net/92zmG/7/ http://jsfiddle.net/92zmG/7/