Angular Material: How to select table row by clicking only the checkbox?

Viewed 4151

I have this angular material table with selection stackblitz from angular material website.

This table with selection allows you to select the table row by clicking the checkbox and any other space outside the checkbox but within the row.

What changes should I make to make selection of table row by only the checkbox?

1 Answers

Remove (click)="selection.toggle(row)" from the last tr it should be

 <tr mat-row *matRowDef="let row; columns: displayedColumns;">
  </tr>

instead of

 <tr (click)="selection.toggle(row)" mat-row *matRowDef="let row; columns: displayedColumns;">
  </tr>

demo

Related