I want to configure an angular $resource. This $resource should allows to call distant web services.
// Gets all the nested-resources of a parent-resource
1) GET /parent-resource/nested-resources
// Gets a nested-resource by id
2) GET /nested-resource/{id}
// Create a nested resource
3) POST /nested-resource
In my scenario, i want retrieve all the nested resources using the first web service. When a nested resource is modified by the user, the nested resource will be save using the third web service.
var NestedResource = $resource('/nested-resource/:id');
Publishable.prototype.isNew = function() {
return this.id === undefined;
};
... lot of functions...
This configuration works well to hit the 2nd and 3rd web services but how can i configure the resource to use the 1st. Several functions are register on the nested resource prototype, i would like to avoid the creation of a specific $resource.
Publishable.prototype.getByParentId = function(parentId) {
// ??
}