【发布时间】:2018-04-13 19:36:40
【问题描述】:
每当服务器出现错误时,我在我的 Angular 应用程序中使用 Angular 材质 dialogcomponent 来打开一个对话框。
如果同时出现多个错误,它会打开多个对话框,这对我来说很好。我想使用closeAll 方法一次关闭所有对话框。
当尝试使用closeAll 方法时出现此错误:
error TS2339: Property 'closeAll' does not exist on type 'MatDialogRef<DialogComponent, any>'.
我如何打开对话框:
constructor(private dialog: MatDialog) {}
const dialogRef = this.dialog.open(DialogComponent, {
width: "500px",
height: "500px",
disableClose: true,
hasBackdrop: true,
data: { name: this.name, animal: this.animal }
});
DialogComponent.ts
onClose(): void {
this.dialogRef.closeAll();
}
@NgModule({
declarations: [
DialogComponent,
...
],
imports: [
MatDialogModule,
BrowserAnimationsModule,
...
],
providers: [
...
],
entryComponents: [ DialogComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
谁能帮帮我?
【问题讨论】:
标签: angular angular-material angular-material-5