angular - 如何在 mat-select 中显示一个值而不在 mat-option 内?
问题描述
就我而言,我使用的formcontrolName
是mat-select
. 我想在选项下拉列表中显示一个值mat-select
,但不在选项下拉列表中:
<mat-select #objet formControlName="cars" >
<mat-option *ngFor="let f of listCars" [value]="f">{{f.name}}</mat-option>
</mat-select>
感谢您的帮助!
解决方案
<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>
推荐阅读
- mysql - 修复自动增量键 mysql 数据库的顺序
- spring-boot - Spring Security 5 OAuth2 WebClient [client_authorization_required] 客户端注册 ID 所需的授权:假人”
- node.js - 节点承诺链是否无法同步执行?
- php - 如何在limesurvey中上传文件
- python - 机器人框架 - UnicodeDecodeError:“ascii”编解码器无法解码位置 49 的字节 0xe9:输入文本时序数不在范围内(128)
- html - 为什么我的元素的内容区域超出其父元素?
- c++ - 可以乘一个旋转矩阵来旋转方向向量(vec 3)吗?
- lua - 有没有更快的方法在 lua 中找到素数?
- javascript - 优化在对象中查找嵌套属性的功能?
- r - 在 R 中创建新对象