Angular - is there a way to get the cell id on click

625 Views Asked by At

I would like to click on any cell of my mat-table and get the row and column of my cell.

I know that with this code I get the clicked row, but I can't figure out how to get the correspondent column.id

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

There are 1 best solutions below

2
Zerotwelve On

you need to set the (click) event in the <td> element instead of <tr>