'mat-dailog afterClosed().subscribe() respose was execute later

async alertdailogbox(string: any) {
    let returndata: any
    let alert = await this.dailog.open(AlertDailogComponent, { data: { msg: string } })
    alert.afterClosed().subscribe((r: any) => {
      returndata = r
      console.log(returndata, "return data in sub")
    })
    console.log(returndata, "return data")
    return returndata
  }

Here I want to return the response value in this method



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source