Last active
August 29, 2015 14:02
-
-
Save cpoDesign/1691ed7fab6358a1f11b to your computer and use it in GitHub Desktop.
using $resource in examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'} | |
}} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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