Angular push to an array within an array

Angular push to an array within an array
0

Hi,

In my angular project I would like to push a number to an array within an array

I am not sure this is the correct way as it doesn’t seem to be working

addNewOrder(order_id) {
      console.log('ORDER_ID: ', order_id);
      this.Ordersummary.subscribe(
        os => {
          os.push(this.Orderlist = order_id);
          order_id.next(os);
        });
  }

I would like to have something like the following:

Orderlist [{
    order_id: 1,
    order_summary: [
        {
        this: 'that',
        here: 'now'
    },
{
        this: 'that again',
        here: 'now then'
    }]
}]

when you click add new order to get the following:

Orderlist [{
    order_id: 1,
    order_summary: [
        {
        this: 'that',
        here: 'now'
    },
{
        this: 'that again',
        here: 'now then'
    }]
},
{
    order_id: 2,
    order_summary: [
        {
        this: 'that2',
        here: 'now2'
    },
{
        this: 'that again2',
        here: 'now then2'
    }]
}]

I’m a little confused about what exactly you’re trying to update. Are you trying to emit a new value in the Ordersummary observable?

Hi, yes, I am trying to add a record to the OrderList so that then I can add in an array of OrderSummary items