I have built an Angular Material Table and would like to use class error-text
if the [dataSource] returns isActive=false.
I'm trying to do this with no luck:
<table
mat-table
[dataSource]="dataSource"
matSort
class="mat-elevation-z8 table table-striped"
[ngClass]="dataSource?.isactive == 'false' ? 'error-text' :''"
>
My class isn't applied to the table.
I understand that I can apply this class to each row of my table, but this seems like the incorrect solution to me:
<ng-container matColumnDef="fullname">
<th mat-header-cell *matHeaderCellDef mat-sort-header>
{{ translate("name") }}
</th>
<td
mat-cell
*matCellDef="let element"
[ngClass]="element?.isactive == 'false' ? 'error-text' :''"
>
{{ element.fullname }}
</td>
</ng-container>
Has anyone found a solution where I can simply state the ngClass once and it is applied to the whole table?