Home > Back-end >  afterClosed() executing early for dialogRef
afterClosed() executing early for dialogRef

Time:10-14

In Test.component.ts I have an on click function in which I have dialog.open() and dialog.afterClosed() In test-dialog.component.ts, I do some basic code after that I have dialogRef.close()

The issue here for me is after when dialog.open() has started executing, dialog.afterClosed() begins execution. Later in dialog component when .close() is called I am not able to get any of the functionality of functions that I had called inside afterClosed().

CodePudding user response:

see that is:

//you get a reference of the dialog "dialogRef"
const dialogRef = this.dialog.open(...))

//you listen the reference to close "dialogRef"
dialogRef.afterClosed().subscribe(..)

You "dialog" has a button

//you pass the value of "object" -the property of [mat-dialog-close]-
//can be a simple variable or a object or array
<button mat-button 
    [mat-dialog-close]="object" >Ok</button>
  • Related