从焦点上和离开焦点时的材料输入中删除标签

pro*_*ina 3 angular-material angular

我正在使用带有占位符的角度材料输入。当我专注于字段时,我会删除占位符,但如果我离开焦点并且字段为空,我会看到变换动画,我也想删除它。在此图像占位符中,该占位符必须是字段为空时的值。

在此输入图像描述

在这张图片中,我留下了焦点:

在此输入图像描述

<mat-form-field class="al-subscribe-form-field">
        <input formControlName="email" matInput type="email">
        <mat-placeholder  class="al-placeholder">{{'SHARED.ENTER_YOUR_EMAIL' | translate}}</mat-placeholder>
</mat-form-field>

.mat-focused .al-placeholder, .mat-form-field-invalid .al-placeholder {
    display: none!important;
}
Run Code Online (Sandbox Code Playgroud)

Kam*_*ski 6

尝试添加floatLabel='never'

<mat-form-field floatLabel='never' class="al-subscribe-form-field" >
    ...
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)