angular - mat-select 在我点击它之前不会显示
问题描述
mat-select 在我单击它之前不会显示,也不会显示值。
HTML
<mat-form-field class="select" appearance="fill">
<mat-label>Flex property</mat-label>
<mat-select placeholder="Choose property" [(ngModel)]="selectedItem">
<mat-option *ngFor="let prop of flexProperties" [value]="prop.value">
{{prop.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
TS
selectedItem: string;
flexProperties: flexProps[] = [
{value: 'flexDirection', viewValue: 'flex-direction'},
{value: 'justifyContent', viewValue: 'justify-content'},
{value: 'flexWrap[enter image description here][1]', viewValue: 'flex-wrap'},
{value: 'flexFlow', viewValue: 'flex-flow'},
{value: 'order', viewValue: 'order'},
{value: 'alignItems', viewValue: 'align-items'},
{value: 'alignSelf', viewValue: 'align-self'},
{value: 'alignContent', viewValue: 'align-content'},
{value: 'flexGrow', viewValue: 'flex-grow'},
{value: 'flexShrink', viewValue: 'flex-shrink'},
{value: 'flexBasic', viewValue: 'flex-basic'}
]
这是 select 在选定选项 [1] 之后的样子:https ://i.stack.imgur.com/K8Yt1.png
解决方案
如果你只想在你的 mat-select 中显示一些信息,你可以这样做:
<mat-form-field class="select" appearance="fill">
<mat-label>Flex property</mat-label>
<mat-select placeholder="Choose property" [(ngModel)]="selectedItem">
<mat-option>Choose property</mat-option>
<mat-option *ngFor="let prop of flexProperties" [value]="prop.value">
{{prop.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
推荐阅读
- python - Python xlsxwriter,导出到网络驱动器
- python - 使用 selenium 从 url 列表中下载多个 pdf
- wordpress - 使用 WordPress REST API 为用户分配角色
- javascript - Ramda JS 如何使用 2 个 json 文件映射特定值
- javascript - 在颜色选择器中获取背景颜色
- c# - 在服务器端的 Blazor 下使用 SignInManager.SignInAsync(.......) 时,它会引发异常
- python - Luigi 处理具有多个依赖任务的缺失任务
- firebase - Firebase 图像大小调整扩展。引用调整大小的图像
- java - 如何将正则表达式与后跟日期的单词匹配?
- xml - XSLT 从 XML 到 XML