Angular 4 Material table highlight a row

后端 未结 7 1712
栀梦
栀梦 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条回答
  •  -上瘾入骨i
    2020-12-08 07:04

    This will allow you to select multiple rows if the row is not previously selected and on clicking again it will deselect it.

    HTML

    
    

    Type Script

    Create an array

    highlightedRows = [];
    

    Define the findOut function

    findOut(row){
      if(this.highlightedRows.indexOf(row) === -1){
        this.highlightedRows.push(row);
        }
        else{
        
          this.highlightedRows[this.highlightedRows.indexOf(row)] = -1;
        }
        
      }
    

提交回复
热议问题