Reputation: 525
When I do:
<mat-form-field class="mat-form-field-invalid">
<mat-label>ID</mat-label>
<input matInput [(ngModel)]="this.testData">
</mat-form-field>
It puts a red underline on the field, but when I do:
<mat-form-field [ngClass]="{'mat-form-field-invalid':true}">
<mat-label>ID</mat-label>
<input matInput [(ngModel)]="this.testData">
</mat-form-field>
It doesn't put the red underline. Am I missing something here?
Upvotes: 1
Views: 1014
Reputation: 137
ngClass doesn't work with <mat-form-field>
You can use below syntax-
<mat-form-field [class.mat-form-field-invalid]="true">
Upvotes: 2