javascript - matDialog上不存在Angular Material beforeClosed和afterAllClosed
问题描述
我正在尝试在我的视图上实现 matDialog,但在尝试使用 beforeClosed 时出错,它说它不是一个函数,但它在 matDialog 上也不存在。afterAllClosed 也是如此。
谁能帮助我?
Dialog:MatDialog;
constructor( Dialog:MatDialog ){ this.Dialog = Dialog; }
const DialogConfig = new MatDialogConfig();
DialogConfig.autoFocus = true;
DialogConfig.data = Provider;
this.Dialog.open(DialogComponent, DialogConfig);
this.Dialog.beforeClosed().subscribe(result => {
console.log(`Dialog result: ${result}`);
})
类型“MatDialog”上不存在属性“beforeClosed”
错误类型错误:this.Dialog.beforeClosed 不是函数
解决方案
抱歉,我找到了解决方案,我需要获取正在打开的对话框的实例。
let CurrentDialog = this.Dialog.open(ProviderEditorComponent, DialogConfig);
CurrentDialog.beforeClosed().subscribe(result => {
console.log(`Dialog result: ${result}`);
});
推荐阅读
- r - 使用字符串元素制作向量
- css - 具有相同 CSS 的模态中的异常结果
- excel - 为什么我的 excel 宏在另一台计算机上的工作方式不同?
- database - 如何在 PHP Unit 8.0 或更高版本中使用数据库执行单元测试
- react-native - How to get Theme type (Typescript) from react-navigation
- anaconda - Anaconda Navigator 向我展示了旧版本的软件包
- java - 当应用程序从后台进入前台时,onBackPress() 不起作用
- android - 如何从 laravel 获取设备令牌以发送推送通知?
- python - 尝试安装较新的 python 版本时在 Windows 中获取“已安装此产品的另一个版本...”
- javascript - Amcharts 和弦图按特定值对节点进行排序