Angular 4 Material table highlight a row

后端 未结 7 1714
栀梦
栀梦 2020-12-08 06:14

I\'m looking for a good way to highlight the whole a row in md-table.
Should I do directive or what?



        
7条回答
  •  一生所求
    2020-12-08 06:51

    Building on Zuzzie's answer, which is the solution that mostly worked for me, I did the following:

    HTML:

    
    
    
    

    add variable to TS:

    selectedRow : boolean;
    

    add this function to TS:

    onRowClicked(row) {
    
       if(!this.selectedRow)
       {
         this.selectedRow = row;
       }   
       else
       {
         this.selectedRow = row;
       }
    
    }
    

    (S)CSS

    .selected {
      background-color: red;
    }
    

提交回复
热议问题