Skip to content

Commit 91ef3a3

Browse files
wesleychobtford
authored andcommitted
docs($resource): fix example using promise
1 parent cea44b3 commit 91ef3a3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ngResource/resource.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function shallowClearAndCopy(src, dst) {
253253
254254
```js
255255
var User = $resource('/user/:userId', {userId:'@id'});
256-
var user = User.get({userId:123}, function() {
256+
User.get({userId:123}, function(user) {
257257
user.abc = true;
258258
user.$save();
259259
});
@@ -273,6 +273,16 @@ function shallowClearAndCopy(src, dst) {
273273
});
274274
});
275275
```
276+
*
277+
* You can also access the raw `$http` promise via the `$promise` property on the object returned
278+
*
279+
```
280+
var User = $resource('/user/:userId', {userId:'@id'});
281+
User.get({userId:123})
282+
.$promise.then(function(user) {
283+
$scope.user = user;
284+
});
285+
```
276286
277287
* # Creating a custom 'PUT' request
278288
* In this example we create a custom method on our resource to make a PUT request

0 commit comments

Comments
 (0)