In Angular, how can I render a material style conditionally?
For example, I want to only apply the style
.mat-form-field-appearance-outline .mat-form-field-infix{
padding-right: 2.3em;
}
to my Password form field text and only when both input boxes have input.
See below:
As you can see, the padding-right is being applied to the Email form field text as well. However, I only want this padding-right to be applied to the bottom form field text, when both input boxes have input, so the text does not go over the submit button.
My .html:
<mat-form-field appearance="outline" hideRequiredMarker>
<mat-label>Email</mat-label>
<input
matInput
[(ngModel)]="emailLoginInput"
style="caret-color: white"
/>
</mat-form-field>
<mat-form-field appearance="outline" hideRequiredMarker>
<mat-label>Password</mat-label>
<input
matInput
[(ngModel)]="passwordLoginInput"
type="password"
style="caret-color: white"
/>
<div
[ngStyle]="{'visibility': passwordLoginInput.length && emailLoginInput.length ? 'visible' : 'hidden'}"
class="continue-button"
(click)="loginAccount()"
>
<img
src="../../../assets/login/login-arrow.svg"
alt="Continue"
/>
</div>
</mat-form-field>
How can I achieve this?
Thanks in advance.
mat-form-field
ofpassword
and then add more concrete .css style rule? Hence, padding will be applied only to the password element. – hastrb