Search code examples
javascriptangularnotificationstoastr

render another page after toastr notification in angular


i am trying to render navigate another page after toastr notification disappear.

  showToasterWarning(){
    this.notifyService.showWarning("No Data Found for this Date!", "");
    
}

notifyService is a service for toastr.

In my code :

if(array == []){
this.showToasterWarning();
}

After notification disappear that mean after 4 or 5 second i want to to navigate another page using:

this.router.navigate(..........);

Only after toastr disappear i want to go to another page.

Any option in ngx-toastr to do whatever after notification disappear?


Solution

  • Please try this!

    this.toastr.info('No Data Found for this Date!')
          .onHidden 
          .subscribe(() => this.router.navigateByUrl('......'));
    })