yangular icon indicating copy to clipboard operation
yangular copied to clipboard

dialogRef.afterClose().toPromise() not working

Open EzyHow opened this issue 5 years ago • 4 comments

Not able to convert afterClose() observable to promise.

Check here: https://stackblitz.com/edit/angular-material-animation-wkxojh?file=app/dialog-overview-example.ts Below code is not working as expected:

dialogRef.afterClosed().toPromise().then(() => {
      alert('closed');
    }).catch(() => {
      alert('error');
    });

Please check

EzyHow avatar Nov 26 '19 06:11 EzyHow

@EzyHow if you take a look at library you need to use something like

  this.dialogRef
      .open(EditUserComponent, {
        animation: { to: "left" },
        role: "dialog",
      })
      .afterClosed()
      .subscribe((arg) => {
        console.log("Back from the dialog");
      });

ankitvadariya avatar Aug 23 '20 05:08 ankitvadariya

Updated example of @EzyHow https://stackblitz.com/edit/angular-material-animation-61jy9f?file=app/dialog-overview-example.ts

ankitvadariya avatar Aug 23 '20 05:08 ankitvadariya

@yantrab
this npm is still maintainable? The current Angular version is 13 though :-)

nerd-cs avatar Dec 23 '21 15:12 nerd-cs

@yantrab this npm is still maintainable? The current Angular version is 13 though :-)

you can open PR, it is open source... :smiley:

yantrab avatar Jan 26 '22 20:01 yantrab