Skip to content

Instantly share code, notes, and snippets.

@evangalen
Last active December 15, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evangalen/5191307 to your computer and use it in GitHub Desktop.
Save evangalen/5191307 to your computer and use it in GitHub Desktop.
AngularJS module "ngResourceWithDefaultUpdateAction" which add a default "update" action to every $resource.
angular.module('$resource-with-update-action', ['ngResource'], function($provide) {
$provide.decorator('$resource', function($delegate) {
var decoratedResourceFactory = function(url, paramDefaults, actions) {
var actionsWithDefaultUpdateAction =
angular.extend({}, { 'update': { method:'PUT' } }, actions);
return $delegate(url, paramDefaults, actionsWithDefaultUpdateAction);
};
return decoratedResourceFactory;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment