|
22 | 22 | * `/user/:username`. |
23 | 23 | * |
24 | 24 | * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in |
25 | | - * `actions` methods. |
| 25 | + * `actions` methods. If any of the parameter value is a function, it will be executed every time |
| 26 | + * when a param value needs to be obtained for a request (unless the param was overriden). |
26 | 27 | * |
27 | 28 | * Each key value in the parameter object is first bound to url template if present and then any |
28 | 29 | * excess keys are appended to the url search query after the `?`. |
|
46 | 47 | * resource object. |
47 | 48 | * - `method` – {string} – HTTP request method. Valid methods are: `GET`, `POST`, `PUT`, `DELETE`, |
48 | 49 | * and `JSONP` |
49 | | - * - `params` – {object=} – Optional set of pre-bound parameters for this action. |
| 50 | + * - `params` – {Object=} – Optional set of pre-bound parameters for this action. If any of the |
| 51 | + * parameter value is a function, it will be executed every time when a param value needs to be |
| 52 | + * obtained for a request (unless the param was overriden). |
50 | 53 | * - isArray – {boolean=} – If true then the returned object for this action is an array, see |
51 | 54 | * `returns` section. |
52 | | - * - `headers` – {object=} – Optional HTTP headers to send |
| 55 | + * - `headers` – {Object=} – Optional HTTP headers to send |
53 | 56 | * |
54 | 57 | * @returns {Object} A resource "class" object with methods for the default set of resource actions |
55 | 58 | * optionally extended with custom `actions`. The default set contains these actions: |
@@ -316,6 +319,7 @@ angular.module('ngResource', ['ng']). |
316 | 319 | var ids = {}; |
317 | 320 | actionParams = extend({}, paramDefaults, actionParams); |
318 | 321 | forEach(actionParams, function(value, key){ |
| 322 | + if (isFunction(value)) { value = value(); } |
319 | 323 | ids[key] = value.charAt && value.charAt(0) == '@' ? getter(data, value.substr(1)) : value; |
320 | 324 | }); |
321 | 325 | return ids; |
|
0 commit comments