【问题标题】:Click event only working on first page of table Angular 8单击事件仅适用于表格 Angular 8 的第一页
【发布时间】: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


    【解决方案1】:

    当它发生在我身上时,我发现底层数据库中的数据只有第一页是完整的,而其余数据不完整,因此查询返回了一个空对象。

    【讨论】:

      猜你喜欢
      • 2014-06-02
      • 1970-01-01
      • 2018-06-26
      • 2017-03-11
      • 2022-01-24
      • 2017-11-01
      • 2017-02-20
      • 2014-11-22
      • 1970-01-01
      相关资源
      最近更新 更多