Angular 对话框关闭后调用函数

Angular 对话框关闭后调用函数,angular,typescript,dialog,Angular,Typescript,Dialog,我试图在关闭对话框后实现函数调用,但我无法使用管道,也无法订阅它。让我们看看我的代码 我得到了这个错误: Type 'Observable<any>' is not assignable to type 'MatDialogRef<any, any>'.   Property '_overlayRef' is missing in type 'Observable<any>' 错误消息几乎完全说明了问题所在:从方法返回的对象的类型不正确 要解决这个问题,

我试图在关闭对话框后实现函数调用,但我无法使用管道,也无法订阅它。让我们看看我的代码

我得到了这个错误:

Type 'Observable<any>' is not assignable to type 'MatDialogRef<any, any>'.   Property '_overlayRef' is missing in type 'Observable<any>' 

错误消息几乎完全说明了问题所在:从方法返回的对象的类型不正确


要解决这个问题,我们需要创建并存储新对话框,然后创建订阅,最后返回刚刚创建的对话框对象

abrirModal(component: ComponentType<any>, dados: any, event: any = null): MatDialogRef<any, any> {
    this.windowScrolling.disable();

    // Create and store dialog object
    const dialog = this.dialog.open(component, {minWidth: '90%', disableClose: true, data: dados, position: {top: '4%'}});

    // Create subscription
    dialog.afterClosed().subscribe(() => {
        // Do stuff after the dialog has closed
        this.windowScrolling.disable();
    });

    // Return dialog object
    return dialog;
}
abrirmodel(组件:组件类型,数据集:任意,事件:任意=null):MatDialogRef{
此参数为.windowScrolling.disable();
//创建和存储对话框对象
const dialog=this.dialog.open(组件,{minWidth:'90%',disableClose:true,数据:dados,位置:{top:'4%});
//创建订阅
dialog.afterClosed().subscribe(()=>{
//在对话框关闭后执行操作
此参数为.windowScrolling.disable();
});
//返回对话框对象
返回对话框;
}
abrirModal(component: ComponentType<any>, dados: any, event: any = null): MatDialogRef<any, any> {
    this.windowScrolling.disable();

    // Create and store dialog object
    const dialog = this.dialog.open(component, {minWidth: '90%', disableClose: true, data: dados, position: {top: '4%'}});

    // Create subscription
    dialog.afterClosed().subscribe(() => {
        // Do stuff after the dialog has closed
        this.windowScrolling.disable();
    });

    // Return dialog object
    return dialog;
}