我想为下拉列表设置默认值。默认值应该是第一个元素。
<select id="myfrm" formControlName="size" required>
<option *ngFor="let size of size.num" value={{size.id}}>
{{size.value}}
</option>
</select>
答案 0 :(得分:0)
绑定selected
的{{1}}属性以设置默认选择。
示例:options
[selected]="selectedValue === size.value"
Stackblitz Snippet:
https://stackblitz.com/edit/angular-o7lpgw?file=src%2Fapp%2Fapp.component.html