我需要创建一个没有浮动标签的选择字段,但是我想要有占位符和默认值。
我阅读了文档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>
无论如何我得到了浮动标签。我做错了什么吗?