Further to my comment, I am adding this answer in case someone finds it helpful. It solves my original problem but I don't know if it's the best solution.
Original factory:
app.factory("customerResource", function ($resource) {
var customerResource = $resource("/api/customer/:id", { id: "@id" });
return customerResource;
});
Original line in controller:
$scope.customers = customerResource.query();
Amended factory:
app.factory("customerResource", function ($resource) {
var customerResource = $resource("/api/:action/:id", { id: "@id", action: "@action" });
return customerResource;
});
Amended line in controller:
$scope.customers = customerResource.query({action: "get");
Now I can use other $resource functions using a different action, like so:
drawing.$remove({action: "delete"});
These calls will reach the Get
and Delete
ActionMethods on the ASP.MVC server.