[英]Can't bind to 'shouldLabelFloat' since it isn't a known property of 'input'
Based on the api documentation , shouldLabelFloat
is a property of MatInput
.基于对API文档,
shouldLabelFloat
是的属性MatInput
。 But I'm still getting the error.但我仍然收到错误。
<mat-form-field>
<input matInput [shouldLabelFloat]="true" placeholder="First Name">
</mat-form-field>
After a bit of digging, it looks like the documentation site is a bit broken and shows properties that are meant to be private.经过一番挖掘,看起来文档站点有点损坏,并显示了本应私有的属性。 There's currently a pull request that was already merged with this fix to remove private getters.
当前有一个已与此修复程序合并的拉取请求以删除私有 getter。 Here's the code for more info.
这是了解更多信息的代码。
Anyways, the correct property to use is the floatLabel
input of MatFormField
as follows:不管怎么说,正确的属性使用的是
floatLabel
的输入MatFormField
如下:
<mat-form-field floatLabel="always">
<input matInput [(ngModel)]="firstName" placeholder="First name">
</mat-form-field>
The floatLabel
input accepts three properties: auto
, always
or never
. floatLabel
输入接受三个属性: auto
、 always
或never
。
Here's some references:这里有一些参考:
You should user inside mat-form-field
您应该在
mat-form-field
<mat-form-field shouldLabelFloat="true">
<input matInput type="text" [(ngModel)]="firstName" placeholder="First Name">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.