简体   繁体   English

AngularJS在$ http中发送数组

[英]AngularJS send array in $http

I've a data like this: 我有这样的数据:

{
  id: 1,
  list: {name: "foo"},{name: "bar"}
}

And send it with AngularJS $http : 并使用AngularJS $http发送:

$http({
  method: "GET",
  url: "url",
  params: data
}).then(function(result){
  console.log(result);
});

In server it will send like this 在服务器中它将像这样发送

id: 1
list: {"name": "foo"}
list: {"name": "bar"}

And if I print_r the value in PHP only the last list was received how can I make it an array? 如果我在PHP中使用print_r的值,仅接收到最后一个列表 ,如何将其设置为数组?

{
  id: 1,
  list: [{name: "foo"},{name: "bar"}]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM