'PrimeNG p-dropdown options from an array inside an object

I have object that contains lots of data relevant to the page and I would like to set the p-dropdown to an subArray within this object, is this possible?

Example of object:

this.tempHouse = {
  houses: [
    {
      house: 'House 1',
      houseId: '123',
    },
    {
      house: 'House 2',
      houseId: '456',
    },
  ],
}

Example of the HTML p-dropdown:

<p-dropdown [options]="tempHouse" optionLabel="houses.house" optionValue="houses.houseId"></p-dropdown>

Thanks



Solution 1:[1]

please try this:

<p-dropdown [options]="tempHouse.houses" optionLabel="house" optionValue="houseId"></p-dropdown>

Solution 2:[2]

try this.

<p-dropdown [options]="tempHouse?.houses" optionLabel="house" optionValue="houseId"></p-dropdown>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mateusz ?ciga?a
Solution 2 ByungYong Kang