I am trying to use ngclass for my condition to apply css for the below html code but it was showing error.
I want to use two class that is colorRed & colorOrange
Here is my Two class (CSS)
.colorRed{
color:red;
}
.colorOrange{
color: orange;
}
Here is condition
Here is my html
<ng-container matColumnDef="salaryIncrease">
<th mat-header-cell *matHeaderCellDef mat-sort-header> </th>
<td mat-cell [ngClass]="{'colorRed': element.salaryIncrease>= 5% }" *matCellDef="let element" > {{element.salaryIncreas| currency:'':''}}
</td>
</ng-container>
You are getting template parse error because you are using % symbol during comparison and % symbol can't be used for comparing. Just compare values of percentage.
Also in standard scenario only value is stored for percentage values. % symbol is added only where needed
Working example for you
https://stackblitz.com/edit/angular-5fbpjc?embed=1&file=app/table-basic-example.html