Display Array Objects in Dropdown- Angular Firebase

330 Views Asked by At

I want to display the items from the "cabinet" array in a dropdown. I've tried the below code, but it's not working. Please help.

Component.ts File:

    getProductDetail(id: string) {
    const x = this.productService.getProductById(id);
    x.snapshotChanges().subscribe(
    (product) => {
    const y = product.payload.toJSON() as Product;
    y.$key = id;
    this.cabinet = y['cabinet'];
    console.log("Cabinets",this.cabinet);
    return this.cabinet;
    }

Component.html File

    <div>
    Select Cabinet
    <select 
    [(ngModel)]="selectedCabinetType"
    >
    <option *ngFor="let item of cabinet">
    {{ item }}
    </option>
    </select>
    </div>
0

There are 0 best solutions below