|
39 | 39 | * @param {Object.<Object>=} actions Hash with declaration of custom action that should extend the
|
40 | 40 | * default set of resource actions. The declaration should be created in the following format:
|
41 | 41 | *
|
42 |
| - * {action1: {method:?, params:?, isArray:?, headers:?}, |
43 |
| - * action2: {method:?, params:?, isArray:?, headers:?}, |
| 42 | + * {action1: {method:?, params:?, isArray:?, headers:?, cache:?}, |
| 43 | + * action2: {method:?, params:?, isArray:?, headers:?, cache:?}, |
44 | 44 | * ...}
|
45 | 45 | *
|
46 | 46 | * Where:
|
|
55 | 55 | * - isArray – {boolean=} – If true then the returned object for this action is an array, see
|
56 | 56 | * `returns` section.
|
57 | 57 | * - `headers` – {Object=} – Optional HTTP headers to send
|
| 58 | + * - `cache` – {Object=} - Optional HTTP cache (see cache option for $http) |
58 | 59 | *
|
59 | 60 | * @returns {Object} A resource "class" object with methods for the default set of resource actions
|
60 | 61 | * optionally extended with custom `actions`. The default set contains these actions:
|
|
136 | 137 | * The object returned from this function execution is a resource "class" which has "static" method
|
137 | 138 | * for each action in the definition.
|
138 | 139 | *
|
139 |
| - * Calling these methods invoke `$http` on the `url` template with the given `method`, `params` and `headers`. |
| 140 | + * Calling these methods invoke `$http` on the `url` template with the given `method`, `params`, `headers` and `cache`. |
140 | 141 | * When the data is returned from the server then the object is an instance of the resource type and
|
141 | 142 | * all of the non-GET methods are available with `$` prefix. This allows you to easily support CRUD
|
142 | 143 | * operations (create, read, update, delete) on server-side data.
|
@@ -378,7 +379,8 @@ angular.module('ngResource', ['ng']).
|
378 | 379 | method: action.method,
|
379 | 380 | url: route.url(extend({}, extractParams(data, action.params || {}), params)),
|
380 | 381 | data: data,
|
381 |
| - headers: extend({}, action.headers || {}) |
| 382 | + headers: extend({}, action.headers || {}), |
| 383 | + cache: (action.cache) ? action.cache : false |
382 | 384 | }).then(function(response) {
|
383 | 385 | var data = response.data;
|
384 | 386 |
|
|
0 commit comments