4

Angular 5 I cant get the dropdown menu to display the "category", the category exsist in item.category and categories, and is the same. I've tried with ngModel and ngValue and just value and cant get it to work

<td>
   <select [(ngModel)]="item.category">
        <option style="display:none">select a category</option>
        <option *ngFor="let item of categories" [ngValue]="item.category" value="item.category">{{item.category}}</option>
      </select>
    </td>

1 Answer 1

18

For me work like this:

<select [(ngModel)]="category" id="category">
   <option value="" disabled selected>select a category</option>
   <option *ngFor="let item of categories" [value]="item.category">{{item.category}}</option>
 </select>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.