I am trying to override the css for an Angular-Material component. I am using the
encapsulation:ViewEncapsulation.None
to override in order to avoid the deprecated /deep/
or ::ngdeep
.
so my SCSS looks like this
.some-class {
margin: 50px
}
.some-class .mat-form-field-wrapper {
color: red;
}
and my html looks like this
<div class="input-field">
<mat-form-field appearance="outline" class="some-class">
<mat-label>Password</mat-label>
<input matInput formControlName="password" required />
</mat-form-field>
</div>
but I want to apply the property color: red
only when a boolean is false. I tried to use ngClass but how do I appply the entire selector (.some-class .mat-form-field-wrapper
) in the ngClass syntax.
my HTML with ngclass (incomplete)
<div class="input-field">
<mat-form-field appearance="outline" class="some-class" [ngClass]="{
' *some way to get the class here* ':
!passwordsRequirementSatisfied && f.password.touched
}">
<mat-label>Password</mat-label>
<input matInput formControlName="password" required />
</mat-form-field>
</div>
Is there any way in css or scss that I can assign the entire selector .some-class .mat-form-field-wrapper
to a variable or a placeholder class or a different class so that I can use that variable/placeholder class directly with the [ngClass] syntax.