如何在打字稿中单击表格内的按钮时获取动态表格行数据

Jay*_*h R 1 html-table typescript angular

我正在使用动态表,每行都有一个按钮,单击按钮时,我需要单击的相应行按钮的数据。

我尝试过(单击)事件绑定,但输出为未定义。

<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>
Run Code Online (Sandbox Code Playgroud)

.ts 文件

removeEmployee(tr) {
      console.log(tr);
    }
Run Code Online (Sandbox Code Playgroud)

预期:单击按钮时,应输出表行数据。

显示实际:未定义。

Mar*_*tra 5

更改员工中的行:

<tr *ngFor = "let employee of employees" (click) = "removeEmployee(employee)">
Run Code Online (Sandbox Code Playgroud)