Skip to content

Instantly share code, notes, and snippets.

@cpoDesign
Last active August 29, 2015 14:02
Show Gist options
  • Save cpoDesign/1691ed7fab6358a1f11b to your computer and use it in GitHub Desktop.
Save cpoDesign/1691ed7fab6358a1f11b to your computer and use it in GitHub Desktop.
using $resource in examples
// service with parameters
// How do I not send url template parameters with request body in angular?
// Source: http://stackoverflow.com/questions/19529483/how-do-i-not-send-url-template-parameters-with-request-body-in-angular
resource = $resource(
'http://foo.com/service/:type/:id',
{},
{save: {
method:'PUT',
transformRequest:function(data) {
delete data.type;
delete data.id;
return JSON.stringify(data);
},
params: {type:'@type', id: '@id'}
}}
);
var resource = $resource('http://foo.com/service/:action/');
return {
validateTitle: function(priorityTitle) {
return resource.get(
{
title: priorityTitle,
action: 'ValidateTitle' // will get used in url
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment