I have a mat
table, in which I want to change the Background color
of a particular cell conditionally.
My HTML:
<ng-container matColumnDef="Status">
<mat-header-cell *matHeaderCellDef mat-sort-header>
Status
</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.Status}} </mat-cell>
</ng-container>
I have the color value in the "row" variable with row.statusBgColor
.
I tried with:
<ng-container matColumnDef="Status">
<mat-header-cell *matHeaderCellDef mat-sort-header>
Status
</mat-header-cell>
<mat-cell style="background-color: {{row.statusBgColor}}" *matCellDef="let row"> {{row.Status}}
</mat-cell>
</ng-container>
But that didn't work. Can anyone help me out of this?