简体   繁体   English

如何禁用在输入上方飞行的角材料占位符

[英]How to disable the angular material placeholder flying above the input

I've an Angular Material input.我有一个 Angular Material 输入。 In most forms, when I click on it, I like the behavior(having the placeholder going above the input).在大多数形式中,当我点击它时,我喜欢这种行为(占位符位于输入上方)。 But in some cases I need this place holder to just disappear.但在某些情况下,我需要这个占位符消失。

Also, I need the control to not use some white space "above" the input.另外,我需要控件不要在输入“上方”使用一些空格。

1) Is it possible? 1)有可能吗? How?如何?

2) If not, what would you do to still use the style of the theme(text color, no border, size, ...) of the angular material theme ? 2)如果不是,你会怎么做才能仍然使用angular material主题的主题样式(文本颜色,无边框,大小,...)?

Not sure it helps, but here is an example where I don't want it(the search text): https://stackblitz.com/edit/angular-scgar8不确定它有帮助,但这里有一个我不想要它的例子(搜索文本): https : //stackblitz.com/edit/angular-scgar8

The material field has a floatLabel property. material 字段具有floatLabel属性。

You can set this to never to get your desired result.您可以将其设置为never获得您想要的结果。

<mat-form-field floatLabel="never">
  <input matInput placeholder="search">
</mat-form-field>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM