angular - 在 Angular 的 mat-select 中显示默认选择的选项
问题描述
我在角度 11 中使用 mat select。任何人都可以帮我在 mat-select 中显示选定的选项。我有一个名为Idefault的字段,条件是 IF type.Idefault == true然后将值显示为 mat-select 中的选定选项
添加图片供您参考
<div class="col-sm-6 has-select pr-3">
<mat-form-field appearance="fill" class="pt-1 no-border">
<mat-select formControlName="source" [(ngModel)]="selectedBatchSource" (selectionChange)="changeClient($event.value)" >
<mat-option *ngFor="let type of data$ | async" [value]="type.ctype">
{{type.ctype}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
解决方案
this.heroForm = new FormGroup({
source: new FormControl('your default value here')
]),
推荐阅读
- oracle-apex - Oracle Apex 动态操作未捕获对页面项目的值更改
- laravel-5 - 如何在 Laravel 中创建查询来搜索?
- integration-testing - 如何在 Cypress 中不引入回调地狱的情况下获取多个别名的值?
- jquery - 如果存在多个值,如何循环遍历 json 项?
- laravel - 如何检查从前三个月创建的记录
- javascript - 通过 SendGrid 和 FireBase 发送电子邮件
- python - 如何创建一个 3D 数组,其中第 k 个元素是一个 2x2 矩阵,我为其定义了向量中的系数
- vb.net - 如何在所有表单上更改相同的背景颜色?
- java - 添加注释以自动指示字段的顺序
- azure - Azure 表存储 (412) 前提条件失败