库: Angular Material (material2)
我想使用 MdInputContainer 的 floatPlaceholder 指令,以便占位符/提示永远不会 float 。
我没有看到它在文档中声明了它期望的值:
@Input() floatPlaceholder: Whether the placeholder should always float, never float or float as the user types.
取自:https://material.angular.io/components/input/api
<md-input-container [floatPlaceholder]="false">
<input type="text" mdInput placeholder="Search...">
</md-input-container>
我已经尝试了 false
和 "never"
作为我最好的猜测值,但都没有阻止占位符 float 在输入之上。
最佳答案
您可以将 floatPlaceholder 输入设置为:auto、always、never。
<md-input-container floatPlaceholder="never">
<input type="text"
mdInput
placeholder="Search...">
</md-input-container>
更新( Angular Material 6):
现在你必须使用floatLabel
:
<mat-form-field floatLabel="never">
<input matInput placeholder="Search...">
</mat-form-field>
关于html - Angular Material : how to set floatPlaceholder to never,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45448604/