constructor( private dialog: MatDialog, ) { } const errMsg = this.dialog.open(ErrorMessageDialog); errMsg.afterClosed().subscribe(result => { this.dialog.closeAll(); });