如何禁止angularjs $ http将我的数组参数拆分为多个参数?

时间:2015-06-01 14:35:32

标签: angularjs rest

我是这样写的。

$http({
     params: {
           cql: "select * from Car where Brand in (?) and CreatedBy.obje  ctId in (?) order by updateAt desc",  
           pvalues: [["1", "2"], ["test"]]
        },
     method: "GET",
     url   : URL.CLOUD_QUERY
 });

但是当我检查铬检查员时,它会转换到下面。

cql:select * from Car where Brand in (?) and CreatedBy.objectId in (?) order by updateAt desc
pvalues:["1", "2"]
pvalues:["test"]

我不想得到两个pvalues。我有一个workaroud写这样的pvalues {0:[],1:[]},但我不喜欢这样。

1 个答案:

答案 0 :(得分:1)

将其作为字符串传递,并在服务器端将其转换回数组对象。

$http({
     params: {
           cql: "select * from Car where Brand in (?) and CreatedBy.obje  ctId in (?) order by updateAt desc",  
           pvalues: JSON.stringify([["1", "2"], ["test"]])
        },
     method: "GET",
     url   : URL.CLOUD_QUERY
 });