Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 dropdown menu

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>
like image 331
Mr. Toast Avatar asked Dec 02 '22 10:12

Mr. Toast


1 Answers

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>
like image 121
Lonna Avatar answered Dec 09 '22 11:12

Lonna