angular-resource
Advanced tools
Comparing version 1.5.6 to 1.5.7
/** | ||
* @license AngularJS v1.5.6 | ||
* @license AngularJS v1.5.7 | ||
* (c) 2010-2016 Google, Inc. http://angularjs.org | ||
@@ -64,6 +64,20 @@ * License: MIT | ||
* | ||
* See {@link ngResource.$resource `$resource`} for usage. | ||
* See {@link ngResource.$resourceProvider} and {@link ngResource.$resource} for usage. | ||
*/ | ||
/** | ||
* @ngdoc provider | ||
* @name $resourceProvider | ||
* | ||
* @description | ||
* | ||
* Use `$resourceProvider` to change the default behavior of the {@link ngResource.$resource} | ||
* service. | ||
* | ||
* ## Dependencies | ||
* Requires the {@link ngResource } module to be installed. | ||
* | ||
*/ | ||
/** | ||
* @ngdoc service | ||
@@ -260,2 +274,10 @@ * @name $resource | ||
* | ||
* The Resource instances have these additional methods: | ||
* | ||
* - `toJSON`: It returns a simple object without any of the extra properties added as part of | ||
* the Resource API. This object can be serialized through {@link angular.toJson} safely | ||
* without attaching Angular-specific fields. Notice that `JSON.stringify` (and | ||
* `angular.toJson`) automatically use this method when serializing a Resource instance | ||
* (see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior)). | ||
* | ||
* @example | ||
@@ -412,2 +434,67 @@ * | ||
/** | ||
* @ngdoc property | ||
* @name $resourceProvider#defaults | ||
* @description | ||
* Object containing default options used when creating `$resource` instances. | ||
* | ||
* The default values satisfy a wide range of usecases, but you may choose to overwrite any of | ||
* them to further customize your instances. The available properties are: | ||
* | ||
* - **stripTrailingSlashes** – `{boolean}` – If true, then the trailing slashes from any | ||
* calculated URL will be stripped.<br /> | ||
* (Defaults to true.) | ||
* - **cancellable** – `{boolean}` – If true, the request made by a "non-instance" call will be | ||
* cancelled (if not already completed) by calling `$cancelRequest()` on the call's return | ||
* value. For more details, see {@link ngResource.$resource}. This can be overwritten per | ||
* resource class or action.<br /> | ||
* (Defaults to false.) | ||
* - **actions** - `{Object.<Object>}` - A hash with default actions declarations. Actions are | ||
* high-level methods corresponding to RESTful actions/methods on resources. An action may | ||
* specify what HTTP method to use, what URL to hit, if the return value will be a single | ||
* object or a collection (array) of objects etc. For more details, see | ||
* {@link ngResource.$resource}. The actions can also be enhanced or overwritten per resource | ||
* class.<br /> | ||
* The default actions are: | ||
* ```js | ||
* { | ||
* get: {method: 'GET'}, | ||
* save: {method: 'POST'}, | ||
* query: {method: 'GET', isArray: true}, | ||
* remove: {method: 'DELETE'}, | ||
* delete: {method: 'DELETE'} | ||
* } | ||
* ``` | ||
* | ||
* #### Example | ||
* | ||
* For example, you can specify a new `update` action that uses the `PUT` HTTP verb: | ||
* | ||
* ```js | ||
* angular. | ||
* module('myApp'). | ||
* config(['resourceProvider', function ($resourceProvider) { | ||
* $resourceProvider.defaults.actions.update = { | ||
* method: 'PUT' | ||
* }; | ||
* }); | ||
* ``` | ||
* | ||
* Or you can even overwrite the whole `actions` list and specify your own: | ||
* | ||
* ```js | ||
* angular. | ||
* module('myApp'). | ||
* config(['resourceProvider', function ($resourceProvider) { | ||
* $resourceProvider.defaults.actions = { | ||
* create: {method: 'POST'} | ||
* get: {method: 'GET'}, | ||
* getAll: {method: 'GET', isArray:true}, | ||
* update: {method: 'PUT'}, | ||
* delete: {method: 'DELETE'} | ||
* }; | ||
* }); | ||
* ``` | ||
* | ||
*/ | ||
this.defaults = { | ||
@@ -417,2 +504,5 @@ // Strip slashes by default | ||
// Make non-instance requests cancellable (via `$cancelRequest()`) | ||
cancellable: false, | ||
// Default actions configuration | ||
@@ -419,0 +509,0 @@ actions: { |
/* | ||
AngularJS v1.5.6 | ||
AngularJS v1.5.7 | ||
(c) 2010-2016 Google, Inc. http://angularjs.org | ||
License: MIT | ||
*/ | ||
(function(P,d){'use strict';function G(t,g){g=g||{};d.forEach(g,function(d,q){delete g[q]});for(var q in t)!t.hasOwnProperty(q)||"$"===q.charAt(0)&&"$"===q.charAt(1)||(g[q]=t[q]);return g}var z=d.$$minErr("$resource"),M=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;d.module("ngResource",["ng"]).provider("$resource",function(){var t=/^https?:\/\/[^\/]*/,g=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}}; | ||
this.$get=["$http","$log","$q","$timeout",function(q,L,H,I){function A(d,h){return encodeURIComponent(d).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,h?"%20":"+")}function B(d,h){this.template=d;this.defaults=v({},g.defaults,h);this.urlParams={}}function J(e,h,n,k){function c(a,b){var c={};b=v({},h,b);u(b,function(b,h){x(b)&&(b=b());var f;if(b&&b.charAt&&"@"==b.charAt(0)){f=a;var l=b.substr(1);if(null==l||""===l||"hasOwnProperty"===l||!M.test("."+ | ||
l))throw z("badmember",l);for(var l=l.split("."),m=0,k=l.length;m<k&&d.isDefined(f);m++){var r=l[m];f=null!==f?f[r]:void 0}}else f=b;c[h]=f});return c}function N(a){return a.resource}function m(a){G(a||{},this)}var t=new B(e,k);n=v({},g.defaults.actions,n);m.prototype.toJSON=function(){var a=v({},this);delete a.$promise;delete a.$resolved;return a};u(n,function(a,b){var h=/^(POST|PUT|PATCH)$/i.test(a.method),e=a.timeout,E=d.isDefined(a.cancellable)?a.cancellable:k&&d.isDefined(k.cancellable)?k.cancellable: | ||
g.defaults.cancellable;e&&!d.isNumber(e)&&(L.debug("ngResource:\n Only numeric values are allowed as `timeout`.\n Promises are not supported in $resource, because the same value would be used for multiple requests. If you are looking for a way to cancel requests, you should use the `cancellable` option."),delete a.timeout,e=null);m[b]=function(f,l,k,g){var r={},n,w,C;switch(arguments.length){case 4:C=g,w=k;case 3:case 2:if(x(l)){if(x(f)){w=f;C=l;break}w=l;C=k}else{r=f;n=l;w=k;break}case 1:x(f)? | ||
(function(P,d){'use strict';function G(t,g){g=g||{};d.forEach(g,function(d,q){delete g[q]});for(var q in t)!t.hasOwnProperty(q)||"$"===q.charAt(0)&&"$"===q.charAt(1)||(g[q]=t[q]);return g}var z=d.$$minErr("$resource"),M=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;d.module("ngResource",["ng"]).provider("$resource",function(){var t=/^https?:\/\/[^\/]*/,g=this;this.defaults={stripTrailingSlashes:!0,cancellable:!1,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"}, | ||
"delete":{method:"DELETE"}}};this.$get=["$http","$log","$q","$timeout",function(q,L,H,I){function A(d,h){return encodeURIComponent(d).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,h?"%20":"+")}function B(d,h){this.template=d;this.defaults=v({},g.defaults,h);this.urlParams={}}function J(e,h,n,k){function c(a,b){var c={};b=v({},h,b);u(b,function(b,h){x(b)&&(b=b());var f;if(b&&b.charAt&&"@"==b.charAt(0)){f=a;var l=b.substr(1);if(null==l||""===l||"hasOwnProperty"=== | ||
l||!M.test("."+l))throw z("badmember",l);for(var l=l.split("."),m=0,k=l.length;m<k&&d.isDefined(f);m++){var r=l[m];f=null!==f?f[r]:void 0}}else f=b;c[h]=f});return c}function N(a){return a.resource}function m(a){G(a||{},this)}var t=new B(e,k);n=v({},g.defaults.actions,n);m.prototype.toJSON=function(){var a=v({},this);delete a.$promise;delete a.$resolved;return a};u(n,function(a,b){var h=/^(POST|PUT|PATCH)$/i.test(a.method),e=a.timeout,E=d.isDefined(a.cancellable)?a.cancellable:k&&d.isDefined(k.cancellable)? | ||
k.cancellable:g.defaults.cancellable;e&&!d.isNumber(e)&&(L.debug("ngResource:\n Only numeric values are allowed as `timeout`.\n Promises are not supported in $resource, because the same value would be used for multiple requests. If you are looking for a way to cancel requests, you should use the `cancellable` option."),delete a.timeout,e=null);m[b]=function(f,l,k,g){var r={},n,w,C;switch(arguments.length){case 4:C=g,w=k;case 3:case 2:if(x(l)){if(x(f)){w=f;C=l;break}w=l;C=k}else{r=f;n=l;w=k;break}case 1:x(f)? | ||
w=f:h?n=f:r=f;break;case 0:break;default:throw z("badargs",arguments.length);}var D=this instanceof m,p=D?n:a.isArray?[]:new m(n),s={},A=a.interceptor&&a.interceptor.response||N,B=a.interceptor&&a.interceptor.responseError||void 0,y,F;u(a,function(a,b){switch(b){default:s[b]=O(a);case "params":case "isArray":case "interceptor":case "cancellable":}});!D&&E&&(y=H.defer(),s.timeout=y.promise,e&&(F=I(y.resolve,e)));h&&(s.data=n);t.setUrlParams(s,v({},c(n,a.params||{}),r),a.url);r=q(s).then(function(f){var c= | ||
@@ -11,0 +11,0 @@ f.data;if(c){if(d.isArray(c)!==!!a.isArray)throw z("badcfg",b,a.isArray?"array":"object",d.isArray(c)?"array":"object",s.method,s.url);if(a.isArray)p.length=0,u(c,function(b){"object"===typeof b?p.push(new m(b)):p.push(b)});else{var l=p.$promise;G(c,p);p.$promise=l}}f.resource=p;return f},function(b){(C||K)(b);return H.reject(b)});r["finally"](function(){p.$resolved=!0;!D&&E&&(p.$cancelRequest=d.noop,I.cancel(F),y=F=s.timeout=null)});r=r.then(function(b){var a=A(b);(w||K)(a,b.headers);return a},B); |
{ | ||
"name": "angular-resource", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"license": "MIT", | ||
@@ -8,4 +8,4 @@ "main": "./angular-resource.js", | ||
"dependencies": { | ||
"angular": "1.5.6" | ||
"angular": "1.5.7" | ||
} | ||
} |
{ | ||
"name": "angular-resource", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"description": "AngularJS module for interacting with RESTful server-side data sources", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
54575
828