Reputation: 525
Below code not applying ngClass.
<table mat-table [dataSource]="dataSourceAB">
<ng-container matColumnDef="Type">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let element" [ngClass]="(element.TxnType=='Credit')?'text-success':'text-danger'"> {{element.TxnType}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumnsAB"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumnsAB;"></tr>
/table>
I am getting the proper data to dispaly but class is not applied. Wts wrong ??
Upvotes: 1
Views: 2956
Reputation: 9687
add text-success
and text-danger
in css
Component.html
<table mat-table [dataSource]="dataSourceAB" class="mat-elevation-z8">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Type </th>
<td mat-cell *matCellDef="let element" [ngClass]="(element.TxnType=='Credit')?'text-success':'text-danger'"> {{element.TxnType}}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumnsAB"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumnsAB;"></tr>
</table>
Upvotes: 3