[英]using Angular's ngResource to pass multiple ids as query parameters
Is there any way to pass an array for a parameter such that the request URL will result in something like: 有什么方法可以传递参数数组,以使请求URL产生以下结果:
GET http://www.myserver.com/products?id=1&id=2&id=3 GET http://www.myserver.com/products?id=1&id=2&id=3
I tried passing an array as one of the query parameters and this was an epic fail: 我尝试将数组作为查询参数之一传递,这是一次史诗般的失败:
productService
.getProducts({
productId: $scope.selectedProductIds
})
.$promise.then(function(result) {
$scope.productData = result;
});
Any ideas? 有任何想法吗?
Please see console [network tab] here http://jsbin.com/kapuje/1/edit 请在此处http://jsbin.com/kapuje/1/edit查看控制台[网络标签]
you can do that in that way : 您可以通过这种方式做到:
var request = {id:[1,2,3,4]};
postageRate.query(request);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.