I'm generating a with *ngFor which doesn't allow me to directly set a "selected" attribute, what is the correct way to do that? I would like the last option to be selected but it doesn't really matter.
<select>
<option
*ngFor="let searchType of dateSearchTypeGroup"
[ngValue]="searchType"
(click)="onSelect(searchType)"
>
{{ searchType.viewValue }}
</option>
</select>
EDIT: thank you for your answers but nothing made it. Iv'e found another solution: as the list i'm iterating on to generate the dropdown list is defined as an array i just set the selected value to the first row of the array:
dateSearchTypeGroup;
selectedSearchType: DateSearchType;
constructor() {
this.dateSearchTypeGroup = dateSearchTypeGroup;
this.selectedSearchType = this.dateSearchTypeGroup[0];
}
And it works just fine.