我需要创建没有浮动标签的选择字段,但我想要有占位符和默认值。
我阅读文档https://material.angular.io/components/form-field/overview#floating-label并尝试自己做。
<mat-form-field [floatLabel]="never">
<mat-select placeholder="All categories" [formControl]="catForm" multiple> //First opportunity for use placeholder
<mat-option *ngFor="let category of categories" [value]="category.name">
{{ category.name }}
</mat-option>
</mat-select>
<!-- <mat-placeholder>All categories</mat-placeholder> -->//Second opportunity for use placeholder
</mat-form-field>
不管怎样,我得到了浮动标签。那我做错了吗?
正确的做法是:
<mat-form-field floatLabel="never">
方括号用于变量。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)