ngfor select option angular 10 code example
Example 1: ngfor select angular
<select [(ngModel)]="passenger.Title">
<option *ngFor="let title of titleArray" [value]="title.Value">
{{title.Text}}
</option>
</select>
Example 2: ngfor in select
<select [(ngModel)]="passenger.Title">
<option *ngFor="let title of titleArray" [value]="title.Value">
{{title.Text}}
</option>
</select>
Example 3: select with ngFor on option and ul
<div>
<ul *ngFor="let sentence of sentences;let i = index;" class="collection">
<li class="collection-item">
<p [ngClass]="{'red': sentence?.disco == 1 , 'green': sentence?.disco == 2 }">{{sentence.viewValue}} </p>
<p style="margin-left:20px; font-size:12px!important">
<select #val (change)="onChange(val.value,i)">
<option *ngFor="let cat of foods" [value]="cat.value" >
{{cat.viewValue}}
</option>
</select>
</p>
</li>
</ul>
</div>