My select control is as below
<select formControlName="productType">
<option *ngFor="let option of optionsArray; let i = index"
[selected]="i===0">
{{ option.name }}
</option>
</select>
In my ts file the optionsArray is a property
@Input( 'options'):IMyOption[]
get optionsArray(): IMyOption[] {
return Object.values( this.options );
}
The options is a input from parent component. All I want is to the select the first item but is always blank. The options are populated from the parent correctly. How can I get [selected] to work? Please help.