Web API に 2 つ以上の get メソッドがあります (以下のように、コード GetProducts と GetProductsNew は get メソッドです)。angular jsのng-resourceを使用しているため、get関数を呼び出そうとすると、あいまいなエラーが発生します。GetProductsNew メソッドを呼び出したいとしたら、どうすれば呼び出せますか? 誰でも助けてください、事前に感謝します:)
// This is my web api code
public class ProductController : ApiController
{
...
public HttpResponseMessage GetProducts()
{
}
public HttpResponseMessage GetProductsNew()
{
}
}
// **This is my angular**
// This is the code in controller.js, using which i am calling the get method from above code, but here the problem is, since the above web api is having the two gt method, i am getting the "Multiple actions were found that match the request"
productcatControllers.controller('ProductListCtrl', ['$scope', '$routeParams',
'$location', '$route', 'productService',
function ($scope, $routeParams, $location, $route, productService)
{
productService.query(function (data) {
$scope.products = data;
});
}]);
// This is the service of angular js
var phonecatServices = angular.module('productcatServices', ['ngResource']);
phonecatServices.factory("productService", function ($resource) {
return $resource(
"/api/Product/:id",
{ id: "@id" },
{
"update": { method: "PUT" }
}
);
});