简体   繁体   中英

open Angular dialog in async methode

I want to open progress dialog by the onclick event. When I click on the button, the dialog is not opened until all async methodes finished. So I want to open the dialog when it begin writing the file. someone any idea how to fix it?

Html

<buton onclick="writeFile"></button>

TS
public async writeFile() {
          const dialogRef  = this.dialog.open(ProgressComponent);
          await this.writePage1()
          await this.writePage2()
          await this.writePage3()
          await this.writePage4()
     }

For somone that has the same issue here How I fixed it. you can use afterOpened() from the dialog to let first the dialog open and run the async methodes.


this.dialog.open(ProgressComponent).afterOpened().subscribe(() => {
       await this.writePage1()
       await this.writePage2()
       await this.writePage3()
       await this.writePage4()
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM