简体   繁体   English

角度材料输入| 如何使'焦点'布局默认

[英]Angular Material input | How to make 'focus' layout default

I'm using Angular Material in my application. 我在我的应用程序中使用Angular Material。 I have input fields like this: 我有这样的输入字段:

<mat-form-field appearance="outline">
  <mat-label>E-mail</mat-label>
  <input matInput placeholder="Indtast e-mail">
</mat-form-field>

Which produces a input form: 这会产生一个输入形式:

在此输入图像描述

Focusing on the input form triggers an animation that transforms the input field to the following layout: 关注输入表单会触发将输入字段转换为以下布局的动画:

在此输入图像描述

Question: Is it possible to have the "focus" layout (label floating in the top left corner) activated by default? 问题:默认情况下是否可以激活“焦点”布局(浮动在左上角的标签)?

We wish to display the placeholder text, also when a field is not focused. 我们希望在字段未聚焦时显示占位符文本。

You may set property floatLabel of mat-form-field to "always": 您可以将mat-form-field的属性floatLabel设置为“always”:

<mat-form-field appearance="outline" floatLabel="always">
  <mat-label>E-mail</mat-label>
  <input matInput placeholder="Indtast e-mail">
</mat-form-field>

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

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