【发布时间】:2021-03-25 02:17:24
【问题描述】:
我使用 Angular Material 创建了一个简单的表格。在一个专栏中,我实现了简单的点击事件。此外,该表具有分页功能,因此每页显示 10 条记录。在第一页我的点击事件正常工作,但在其他页面上它不起作用。如何实现?
<ng-container matColumnDef="changes">
<th mat-header-cell *matHeaderCellDef> Changes </th>
<td mat-cell *matCellDef="let element;let i=index">
<button (click)="change(element)"></button>
</td>
</ng-container>
TS 代码
change(element){
this.input=[];
this.changing=true;
const elementIndex = this.details.findIndex((elem: any) => element === elem);
this.isChanged[elementIndex] = true;
}
我读到了 JQuery 中的事件委托。如何实现类似于在当前不在 DOM 中的元素上实现 click 功能的东西。
【问题讨论】:
标签: html angular typescript dom angular8