Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 999
kaiilim Avatar asked Sep 06 '25 03:09

kaiilim


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

like image 172
jitender Avatar answered Sep 07 '25 22:09

jitender