首页 > 解决方案 > 我为材料表的选择部分写了一个函数

问题描述

我为材料表的选择部分编写了一个函数,但由于某种原因我的函数没有运行

        <ng-container matColumnDef="select" sticky>
          <th mat-header-cell *matHeaderCellDef class="px-2 w-50px">
            <mat-checkbox (change)="$event ? masterToggle() : null" color="warn"
                [checked]="selection.hasValue() && isAllSelected()"
                [indeterminate]="selection.hasValue() && !isAllSelected()"
                [attr.aria-label]="checkboxLabel()">
            </mat-checkbox>
          </th>
          <td mat-cell *matCellDef="let row; let i = index" class="px-2 w-50px">
            <mat-checkbox (click)="selectRow($event, i)" color="warn"
                (change)="$event ? selection.toggle(row) : null"
                [checked]="selection.isSelected(row)"
                [attr.aria-label]="checkboxLabel(row)">
            </mat-checkbox>
          </td>
        </ng-container>
  selectRow(event: any, index: number) {
    console.log('event', index, event);
    event.stopPropagation();
  }

我只想运行此代码,但单击时没有任何反应。我在其中运行的另一个函数是材料表的选定函数。为什么我的代码在单击时不运行可能是什么问题?

标签: angulartypescript

解决方案


推荐阅读