【发布时间】:2013-11-15 16:01:20
【问题描述】:
我最近升级到 AngularJS 1.2.0,但传递数组时出现问题,会破坏网站。在示例 $http 请求中,我正在传递如下字段:
$http.get({
url : 'users',
data : {
fields : 'user_id, user_name',
conditions : {
customer_id : current_site_id
},
join : ['customer_users']
}
});
在 1.0.8 的最后一个稳定版本中,连接的 [] 被保留,因此在 php 端它显示为数组并且是可迭代的。在 1.2.0 中,数组被删除,参数由浏览器传递给服务器:
conditions:{"customer_id":"9a83a3db-673e-407f-9a0d-1f804c4dcd01"}
fields:user_id, user_name
join:customer_users //<---- THIS SHOULD BE AN ARRAY!
因为它不是一个可迭代的对象,所以它破坏了 php 方面。因此,除了将所有数组变量从 ['xyz'] 重命名为 {'0': 'xyz'} 以模仿数组行为(尽管不是最佳的)之外,我如何确保 angularJS 将值作为数组传递?
【问题讨论】:
标签: javascript php angularjs