我需要在选择框中显示占位符,但无法执行。
我尝试了一些禁用的选项值,但是没有用
<div class="input-group">
<select class="form-control" formControlName="bloodgroup">
<option value="" disabled selected>Select your option</option>
<option value="A+">A+</option>
<option value="O+">O+</option>
<option value="B+">B+</option>
<option value="AB+">AB+</option>
<option value="O-">O-</option>
<option value="B-">B-</option>
<option value="AB-">AB-</option>
</select>
</div>
答案 0 :(得分:0)
尝试这样:
HTML:
<select class="form-control" formControlName="bloodgroup">
<option [ngValue]="null" disabled selected>Select your option</option>
<option [ngValue]="A+">A+</option>
<option [ngValue]="O+">O+</option>
</select>
TS:
form = new FormGroup({
bloodgroup: new FormControl(null, Validators.required)
});