首页 > 解决方案 > 如何在 mat-select 中显示一个值而不在 mat-option 内?

问题描述

就我而言,我使用的formcontrolNamemat-select. 我想在选项下拉列表中显示一个值mat-select,但不在选项下拉列表中:

<mat-select #objet formControlName="cars" >
   <mat-option *ngFor="let f of listCars" [value]="f">{{f.name}}</mat-option>
</mat-select>

感谢您的帮助!

标签: angularangular-material

解决方案


<mat-select #objet formControlName="cars" >
   <mat-option *ngFor="let f of listCars" [value]="f">{{f.name}}</mat-option>
</mat-select>
<div>{{ myForm.get("cars")?.value }}</div>

推荐阅读