I am currently working with a dynamic table that has a button in each row. When the button is clicked, I need to retrieve the data from that specific row.
I attempted to use the (click) event binding on <tr>
, but the output I received was undefined.
<table>
<thead> <tr> <th> Name </th> <th> Company </th> </tr> </thead>
<tr *ngFor = "let employee of employees" (click) = "removeEmployee(row)">
<td> <input type="text" [(ngModel)]= "employee.name"></td>
<td> <input type="text" [(ngModel)] = "employee.companyName"> </td>
</tr>
</table>
.ts file
removeEmployee(tr) {
console.log(tr);
}
Expected: Upon clicking the button, the data from the respective row should be displayed.
Actual: The output shows undefined.