0

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>
Riyasree
  • 567
  • 1
  • 4
  • 10
  • 1
    Please don't post screenshots of your code, or other textual content. Instead post the actual text, and use the formatting tools of Stack Overflow to mark it up. – Frank van Puffelen Jun 23 '20 at 20:38
  • Hi Frank, added the code. Could you please check now? – Riyasree Jun 23 '20 at 21:10
  • Can you more explicitly say what isn't working about this code? Is your `subscribe` callback triggered? If so, does the `console.log` show what expect from it? Since we can't debug this code, you're going to have to still do that yourself. – Frank van Puffelen Jun 24 '20 at 00:19

0 Answers0