diff options
| author | Igor Minar | 2010-12-07 16:06:31 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-12-07 16:06:31 -0800 |
| commit | 824eab9029ea2fe36b167523c58d455a009d5064 (patch) | |
| tree | f7456d47b51383e362ba7d60b4d6a0cb0cc1222a /src | |
| parent | d503dfe99bc4e7fa93d64c9d0ca7a6decb36c2cc (diff) | |
| download | angular.js-824eab9029ea2fe36b167523c58d455a009d5064.tar.bz2 | |
improving $resource docs
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 2 | ||||
| -rw-r--r-- | src/services.js | 44 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/Angular.js b/src/Angular.js index d5b5144d..ea5d1ea1 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -699,7 +699,7 @@ function concat(array1, array2, index) { * * @param {Object} self Context in which `fn` should be evaluated in. * @param {function()} fn Function to be bound. - * @param {(...*)=} args Optional arguments to be prebound to the `fn` function call. + * @param {...*} args Optional arguments to be prebound to the `fn` function call. * @returns {function()} Function that wraps the `fn` with all the specified bindings. */ function bind(self, fn) { diff --git a/src/services.js b/src/services.js index ef3de549..f7661310 100644 --- a/src/services.js +++ b/src/services.js @@ -888,7 +888,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer){ /** * @workInProgress - * @ngdoc service + * @ngdoc function * @name angular.service.$resource * @requires $xhr * @@ -934,6 +934,33 @@ angularServiceInject('$xhr.cache', function($xhr, $defer){ expect(newCard.id).toEqual(789); * </pre> * + * The object returned from this function execution is a resource "class" which has "static" method + * for each action in the definition. + * + * Calling these methods invoke `$xhr` on the `url` template with the given `method` and `params`. + * When the data is returned from the server then the object is an instance of the resource type and + * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD + * operations (create, read, update, delete) on server-side data. + + <pre> + var User = $resource('/user/:userId', {userId:'@id'}); + var user = User.get({userId:123}, function(){ + user.abc = true; + user.$save(); + }); + </pre> + * + * It's worth noting that the callback for `get`, `query` and other method gets passed in the + * response that came from the server, so one could rewrite the above example as: + * + <pre> + var User = $resource('/user/:userId', {userId:'@id'}); + User.get({userId:123}, function(u){ + u.abc = true; + u.$save(); + }); + </pre> + * * * @param {string} url A parameterized URL template with parameters prefixed by `:` as in * `/user/:username`. @@ -964,20 +991,7 @@ angularServiceInject('$xhr.cache', function($xhr, $defer){ 'delete': {method:'DELETE'} }; * </pre> * - * @returns {Object} A resource "class" which has "static" method for each action in the definition. - * Calling these methods invoke `$xhr` on the `url` template with the given `method` and - * `params`. When the data is returned from the server then the object is an instance of the - * resource type and all of the non-GET methods are available with `$` prefix. This allows you - * to easily support CRUD operations (create, read, update, delete) on server-side data. - - <pre> - var User = $resource('/user/:userId', {userId:'@id'}); - var user = User.get({userId:123}, function(){ - user.abc = true; - user.$save(); - }); - </pre> - * + * @returns {Object} A resource "class". * * @example <script> |
