Is there any way to combine following two Observable into a array of object in angular?

Suppose we have two observables student$ = from([ {id: 1, name: "Alex"}, {id: 2, name: … Read more Is there any way to combine following two Observable into a array of object in angular?

Suppose we have two observables

 student$ = from([
    {id: 1, name: "Alex"},
    {id: 2, name: "Marry"},
  ])

  address$ = from([
    {id: 1, location: "Chicago", sid: 1},
    {id: 2, location: "Florida", sid: 2},
  ])

I want to combine them into a array of object, the expected result would be following

  studentAddress = [
    {
      id: 1,
      name: "Alex",
      address: [
        {id: 1, location: "Chicago", sid: 1},
      ]
    },
    {
      id: 2,
      name: "Marry",
      address: [
        {id: 2, location: "Florida", sid: 2},
      ]
    },
  ]

Source: JavaSript – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *