【发布时间】:2019-06-28 03:05:53
【问题描述】:
我的选择中有一个选项来过滤我的所有结果和其他选项列表,我可以从我的列表中设置默认选项,但不能将第一个 mat-option 设置为默认值。我该怎么做?
<mat-form-field class="col-md-12 p-0 pb-2">
<mat-select formControlName="carControl">
<mat-option value="0">(All)</mat-option>
<mat-option *ngFor="let item of data.filteredListOfCars" [value]="item" ngDefaultControl>
{{this.codeListService.getNameOfManufacturerById(item.manufacturerId)}} {{item.model}} {{item.ecv}}
</mat-option>
</mat-select>
</mat-form-field>
我正在设置这样的默认值
selectValueInControl(){
this.filterFormGroup.get('statusControl').setValue(0);
}
【问题讨论】:
标签: html angular typescript angular-reactive-forms