小编Mut*_*i K的帖子

如何防止在确认之前更改 MatTab?

我想保留更改MatTab直到得到确认。我已经用来MatDialog确认了。问题是,在单击“是”之前,选项卡已更改。

例如,在收入选项卡中,我单击调整选项卡。在切换到该选项卡之前,我需要先显示弹出窗口。但我在移动到调整选项卡后收到弹出窗口。

显示弹出窗口的图像

组件模板:

 <mat-tab-group (click)="tabClick($event)">
  <mat-tab *ngFor="let tab of tabs; let index = index" [label]="tab">
    <app-spread></app-spread
  </mat-tab>
</mat-tab-group>
Run Code Online (Sandbox Code Playgroud)

组件ts(onClick的方法):

tabClick(clickEvent: any) {
    if (clickEvent.target.innerText != 'First') {
      this.confirm();
    }
  }
  public async confirm() {
    const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
      maxHeight: '200px',
      maxWidth: '767px',
      width: '360px',
      disableClose: true,
      data: {
        title: 'Confirmation Message',
        content:
          'There are valid statements that are not Final. Set the statements as Final?'
      } …
Run Code Online (Sandbox Code Playgroud)

typescript angular-material angular mat-tab

6
推荐指数
1
解决办法
5081
查看次数

标签 统计

angular ×1

angular-material ×1

mat-tab ×1

typescript ×1