Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mat select in Angular中显示默认选定选项_Angular_Typescript_Angular Material - Fatal编程技术网

在mat select in Angular中显示默认选定选项

在mat select in Angular中显示默认选定选项,angular,typescript,angular-material,Angular,Typescript,Angular Material,我在angular 11中使用mat select。有人能帮我在mat select中显示所选选项吗。 我有一个名为Idefault的字段,条件是, 如果type.Idefault==true则在mat select中将值显示为所选选项 已添加图像供您参考 {{type.ctype} this.heroForm=new FormGroup({ 来源:new FormControl('此处为您的默认值') ]),我不太熟悉material api,但您是否可以预先定义这个。在组件中选择sel

我在angular 11中使用mat select。有人能帮我在mat select中显示所选选项吗。 我有一个名为Idefault的字段,条件是, 如果type.Idefault==true则在mat select中将值显示为所选选项

已添加图像供您参考


{{type.ctype}
this.heroForm=new FormGroup({
来源:new FormControl('此处为您的默认值')

]),
我不太熟悉material api,但您是否可以预先定义
这个。在组件中选择selectedBatchSource
以指定默认值?感谢您的回复,但在这里我想在打开表单时显示所选值。当用户从列表中选择选项时,我使用selectedBatchSource从列表中获取所选值。
             <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>