@@ -57,6 +57,24 @@ function shallowClearAndCopy(src, dst) {
57
57
* <div doc-module-components="ngResource"></div>
58
58
*
59
59
* See {@link ngResource.$resource `$resource`} for usage.
60
+ *
61
+ * See {@link ngResource.$resourceProvider `$resourceProvider`} for usage.
62
+ */
63
+
64
+ /**
65
+ * @ngdoc provider
66
+ * @name $resourceProvider
67
+ *
68
+ * @description
69
+ *
70
+ * Use for configuring {@link ngResource.$resource `$resource`} in module configuration phase.
71
+ *
72
+ * ## Example
73
+ * See {@link ngResource.$resourceProvider#defaults `Properties`} for configuring `ngResource`.
74
+ *
75
+ * ## Dependencies
76
+ * Requires {@link ngResource `ngResource`} module to be installed.
77
+ *
60
78
*/
61
79
62
80
/**
@@ -402,6 +420,52 @@ angular.module('ngResource', ['ng']).
402
420
var PROTOCOL_AND_DOMAIN_REGEX = / ^ h t t p s ? : \/ \/ [ ^ \/ ] * / ;
403
421
var provider = this ;
404
422
423
+ /**
424
+ * @ngdoc property
425
+ * @name $resourceProvider#defaults
426
+ * @description
427
+ * A configuration object for `$resource` instances.
428
+ *
429
+ * Properties of this object are initialized with a set of values that satisfies a wide range of use cases.
430
+ * User can also choose to override these properties in application configuration phase.
431
+ *
432
+ * Property `stripTrailingSlashes`, default to true, strips trailing slashes from
433
+ * calculated URLs.
434
+ *
435
+ * Property `actions` is an object that sets up high level methods/aliases on `$resource` object
436
+ * based on standard HTTP methods. Users can supply an "actions" object with method aliases that
437
+ * comply with alternative conventions.
438
+ *
439
+ * To add your own set of configurations, set it up like so:
440
+ * ```
441
+ * angular.module('myApp').config(['resourceProvider', function ($resourceProvider){
442
+ *
443
+ * // Provide your own set of actions on $resource factory.
444
+ * // The following comments are Angular's default actions, which are being
445
+ * // replaced by an object that includes a PUT method as shown.
446
+ * // { 'get': {method:'GET'},
447
+ * // 'save': {method:'POST'},
448
+ * // 'query': {method:'GET', isArray:true},
449
+ * // 'remove': {method:'DELETE'},
450
+ * // 'delete': {method:'DELETE'} };
451
+ *
452
+ * $resourceProvider.defaults.actions = {
453
+ * create:{method: 'POST'},
454
+ * save: {method: 'POST'},
455
+ * update:{method: 'PUT'},
456
+ * get: {method: 'GET'},
457
+ * query: {method: 'GET', isArray:true},
458
+ * remove: {method: 'DELETE'},
459
+ * delete: {method: 'DELETE'}
460
+ * };
461
+ *
462
+ * // Don't strip trailing slashes from calculated URLs.
463
+ * // Consult your application server's configuration to work in concert with this setting.
464
+ * $resourceProvider.defaults.stripTrailingSlashes = false;
465
+ * }]);
466
+ * ```
467
+ *
468
+ */
405
469
this . defaults = {
406
470
// Strip slashes by default
407
471
stripTrailingSlashes : true ,
0 commit comments