我正在尝试使用以下代码与RESTFul服务进行通信:
$scope.makeRequest = function(){
params = {};
params['3'] = 'X';
params['length'] = 5;
var resource = $resource('/foo', {});
var result = resource.query(params, function(){
console.log(result);
});
}
此请求有效,并调用预期的网址:http://localhost:3000/foo?3=X&length=5
但是,当整数字段是'length'字段的值减一:
$scope.makeRequest = function(){
params = {};
params['4'] = 'X';
params['length'] = 5;
var resource = $resource('/foo', {});
var result = resource.query(params, function(){
console.log(result);
});
}
此代码段会忽略“长度”字段,并请求:http://localhost:3000/foo?4=X
我的问题是:
答案 0 :(得分:0)
您是否尝试过设置这样的文字对象:
params = {'4':'X', 'length': '5'}