首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在typescript中使用Mat-Dialog对两个弹出窗口执行delete方法的最佳实现是什么

在typescript中使用Mat-Dialog对两个弹出窗口执行delete方法的最佳实现是什么
EN

Stack Overflow用户
提问于 2021-09-24 02:11:17
回答 2查看 45关注 0票数 0

我正在实现一个对话框,它将打开一个弹出窗口,询问用户是否想要删除,立即下一步是询问评论。

对于第一个(询问是否要删除),代码很好。我使用了相同的方法在级联中实现了这一点,但是文件没有被删除。

代码如下:

代码语言:javascript
复制
deleteRow(i: any) {
        this.dialogService
        .openConfigDialog('Are you really want to delete this file ?')
        .afterClosed()
        .subscribe(async (res) => {
            if (res) {
                
                /* this.reason
                    .openReasonDialog("Please describe the reason for delete")
                    .afterClosed()
                    .subscribe(async (res) => {
                        if (res) { */

                                let deleteRowRequest = {
                                    IstValues: [this.dataSource.data[i]]
                                };
                                this.istManagementService.deleteRecord(this.inputTable, deleteRowRequest).subscribe(
                                    (res: any) => {
                                        this.dataSource.data.splice(i, 1);
                                        this.dataSource._updateChangeSubscription();
                                    }
                                )
                                    
                            /* }}) */
                            
                }
            }
    )
    }
                
                refresh(): void { window.location.reload()}

如果我注释掉,这些文件就会被删除。如果我不评论,它们不会被删除。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-09-24 06:11:24

很难共享所有的代码,因为我的对话框在一个库中,它们被一个服务调用,但我做了一个快速测试,它是这样的。

代码语言:javascript
复制
dialogNotify() {
    let data2: IDialogNotify = {
      title: 'Toolbar Menu',
      warning: 'Toolbar Menu',
      message1: 'The menu toolbar will show...',
      message2: 'NOTICE - When making changes to blah blah.' +
        '  ... depending on the processing power of your device.  Check the Messages indicator on the top right' +
        ' of the screen.',
      confirmButton: 'Ok, I got it',
    };

    this.dialogService.openNotify(data2);
    this.dialogService.openNotifyConfirmed().subscribe((confirmed: any) => {
      if (confirmed) {
        let data2: IDialogNotify = {
          title: 'Toolbar Menu',
          warning: 'Toolbar Menu',
          message1: "error",
          message2: "",
          confirmButton: 'Ok, I got it',
        };

        this.dialogService.openNotify(data2);
        this.dialogService.openNotifyConfirmed().subscribe((confirmed: any) => {
          if (confirmed) {
            this.logger.info('Confirmed: nested dialog');
          }
        });
      }
    });
  }

不知道这是否对你有帮助,但它确实起作用了。你确定你得到的第二个值是真的吗?

票数 1
EN

Stack Overflow用户

发布于 2021-09-27 14:34:23

我把(click)关闭放在对话框关闭的同一行。

重新定位到关闭窗口后,它解决了我的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69308741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档