-1

I have 2 orders in JSON.

[
  {
    "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"
      }
    ]
  }
]

I have to add order #1 details into order #2. How do I add it? it should add details as per booking date.

willdanceforfun
  • 11,044
  • 31
  • 82
  • 122
hetal
  • 11

1 Answers1

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"
        }
      ]
    }
  ]
}

To copy contents of array order1 to order do something like this -

order1[0].order = angular.copy(order2[0].order1);
Amit Sirohiya
  • 333
  • 1
  • 13