我在JSON中有2个订单。
[
{
"Type": "Example",
"booking_date": "2016-03-31T00:00:00.000Z",
"arriving_time": "2016-03-31T00:00:00.000Z",
"vendor": "b3d1d9c076a937929376e21b",
"buffer_time": "2016-03-31T00:00:00.000Z",
"order": [],
"items": []
}
]
[
{
"booking_date": "2016-03-31T00:00:00.000Z",
"order1": [
{
"max_item": "4",
"cost_per_package": "500",
"cost_per_item": "100",
"arrive_before_time": "2016-03-31T00:00:00.000Z"
}
]
}
]
我必须在订单#2中添加订单#1的详细信息。我该如何添加?它应该按照预订日期添加细节。
答案 0 :(得分:0)
<强> Order1 强>
{
"order1": [
{
"Type": "Example",
"booking_date": "2016-03-31T00:00:00.000Z",
"arriving_time": "2016-03-31T00:00:00.000Z",
"vendor": "b3d1d9c076a937929376e21b",
"buffer_time": "2016-03-31T00:00:00.000Z",
"order": [],
"items": []
}
]
}
<强> Order2 强>
{
"order2": [
{
"booking_date": "2016-03-31T00:00:00.000Z",
"order1": [
{
"max_item": "4",
"cost_per_package": "500",
"cost_per_item": "100",
"arrive_before_time": "2016-03-31T00:00:00.000Z"
}
]
}
]
}
要复制数组order1的内容,请执行以下操作 -
order1[0].order = angular.copy(order2[0].order1);