在 Angular 4 (Material) 应用程序中,我有一个用于搜索的文本字段。当我在字段中键入时,会出现第二个字段,显示输入的文本。当我滚动页面时,这个新字段会 float 。如何禁用 float 行为?
这似乎不是文本字段的默认行为。我试过 md-no-float
,但这是我理解的占位符文本。有人建议设置一个空的 value
,所以我添加了它,但问题仍然存在。
<md-input-container md-no-float style="width: 100%">
<input mdInput formControlName="search" value="" placeholder="Search Terms" />
</md-input-container>
最佳答案
根据 @angular/material2 的 6.4.5 版本,您可以使用 floatLabel
输入属性控制 float 标签,如您在其 floating label documentation 中所见。 .
<mat-form-field [floatLabel]="'never'">
关于angular - 禁用 mdInput 文本字段的 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46418625/