我正在尝试将默认选择对象设置为角度6中的选择选项,但是它不起作用
<select name="editUserType" class="form-select" id="editUserType" [(ngModel)]="updateModel.userType">
<option value="" selected disabled>Select User Type</option>
<option *ngFor="let userType of userTypeList" [selected ]="userType.code == updateModel.userType.code" [ngValue]="userType">{{userType.description}}</option>
</select>
userType是我想要的对象,当我加载网页时,将默认对象设置为select选项。
答案 0 :(得分:1)
设置组件的默认值
constructor(){
this.updateModel.userType = ""
}