'How to add specific class on selected material table row (Angular Material Table)?

I want to use the angular material table which should return a class for table row when it triggers click on it.

tableRowClicked() should return the class name.

<tr    mat-row               
       *matRowDef="let row; columns: displayedColumns"               
       [class]="tableRowClicked()"               
       (click)="productSelect(row)"></tr>


 getRowClass(row: any): any {
           return {
    'is-selected': row.id === this.currentId
 };   }

 

tr {     
   &.is-selected{       background: red; }
   }

I tried to change the selected row background color.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source