<select formControlName="businessSizeId">
<option [value]="null">Select size</option>
<option *ngFor="let businessSize of businessSizes" [value]="businessSize.id">
{{businessSize.name}}
</option>
</select>
In component.ts
this.form = this.formBuilder.group({
businessSizeId: [this.businessSizeId],
});
I tried to set a default value using the code above but it is not working.
A:
Use [ngValue] instead of [value]
<select formControlName="businessSizeId">
<option [ngValue]="null">Select size</option>
<option *ngFor="let businessSize of businessSizes" [ngValue]="businessSize.id">
{{businessSize.name}}
</option>
</select>
Autrice di guide su come richiedere preventivi, confrontare servizi e scegliere i fornitori ideali.