0
我奮力傳遞變量的值作爲關鍵查詢參數使用$資源在Angularjs應用GET:
下面是代碼:
//控制器
..
.
var value = obj.value; // Y
var category = obj.category; //ctrlpart
//category contains a dynamic value which needs to go as a key
..
.
scope.materialDataPromise = MaterialData.query(
{
"query" : keyword,
"ftype" : ftype,
category : value,
"start" : 0,
"rows" : 1000
}, function(response) {
所以該請求可以像
http://test.com:8080/JunkAPI/MaterialServlet?query=0091&start=0&rows=1000&crtclpart=Y
& crtclpart = Y
或具有多個動態值
http://test.com:8080/JunkAPI/MaterialServlet?query=0091&start=0&rows=1000&crtclpart=Y&invoice=ALL
& crtclpart = Y &發票= ALL
下面是服務呼叫:
apiService.factory("MaterialData", function ($resource) {
var _url = "http://test.com:8080/JunkAPI/MaterialServlet;
return $resource(_url, {}, {
"query": {
method: "GET",
headers: {
'Content-Type': 'application/json'
}
}
});
});
請建議一些選項來處理這個多個動態值作爲密鑰傳遞給$ resource rest api調用