I'm using Angular 9 and have a Material dialog that is set to return "test" on close like this:
<mat-dialog-actions align='center'>
<button mat-raised-button color='primary' [mat-dialog-close]='"test"'>
Submit
</button>
</mat-dialog-actions>
In my main page component, I'm subscribing to afterAllClosed:
constructor(private matDialog: MatDialog) { }
OpenMatDialog(data): void {
this.matDialog.open(
DialogComponent,
{ data },
);
if( !this.matDialogCloseSub$ )
this.matDialogCloseSub$ = this.matDialog.afterAllClosed.subscribe(result => {
console.log(result);
});
}
However, result always comes back as undefined. What am I doing wrong?
I have set the dialog component in app.module.ts in entrycomponents as follows:
@NgModule({
declarations: [
AppComponent,
DialogComponent
],
imports: [
MatDialogModule,
],
entryComponents: [
DialogComponent,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }