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>
3
  • 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. Commented Jun 23, 2020 at 20:38
  • Hi Frank, added the code. Could you please check now? Commented Jun 23, 2020 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. Commented Jun 24, 2020 at 0:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.