Improve this Doc View Source

Use `$resourceProvider` to change the default behavior of the `$resource` service.

## Dependencies

Requires the `ngResource` module to be installed.

## Properties

- ### `defaults`

  - | 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. (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 `$resource`. This can be overwritten per resource class or action. (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 `$resource`. The actions can also be enhanced or overwritten per resource class. The default actions are:
        {
          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:
      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:
      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'}
          };
        });