简体   繁体   English

无法绑定到“shouldLabelFloat”,因为它不是“input”的已知属性

[英]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输入接受三个属性: autoalwaysnever


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.

相关问题 无法绑定到“ngValue”,因为它不是“input”的已知属性 - Can't bind to 'ngValue' since it isn't a known property of 'input' “无法绑定到‘ngModel’,因为它不是‘输入’的已知属性” - “Can't bind to 'ngModel' since it isn't a known property of 'input' ” 无法绑定到“ngModel”,因为它不是“输入”的已知属性 - Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’ 无法绑定到&#39;mdDatepicker&#39;,因为它不是&#39;input&#39;的已知属性 - Can't bind to 'mdDatepicker' since it isn't a known property of 'input' 无法绑定到“ngModel”,因为它不是“输入”的已知属性 - Can't bind to 'ngModel' since it isn't a known property of 'input' 无法绑定到“上载器”,因为它不是“输入”的已知属性 - Can't bind to 'uploader' since it isn't a known property of 'input' 无法绑定到“测试”,因为它不是“输入”的已知属性 - Can't bind to 'testing' since it isn't a known property of 'input' 无法绑定到“typeahead”,因为它不是“input”的已知属性 - Can't bind to 'typeahead' since it isn't a known property of 'input' 无法绑定到“matDatepicker”,因为它不是“输入”的已知属性 - Can't bind to 'matDatepicker' since it isn't a known property of 'input' 角度-无法绑定到“属性”,因为它不是“ a”的已知属性 - Angular - Can't bind to 'property' since it isn't a known property of 'a'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM