Angular router: promise returned from navigatebyurl is ignored

Sammy

Using this code:

this.router.navigateByUrl('/login');

I get the following warning: promise returned from navigatebyurl is ignored. How and when would I want to handle the promise here?

P.S. I'm using this in AuthGuard's canActivate.

Amir BenAmara

The navigateByUrl function returns a promise so you can use .then() method :

this.router.navigateByUrl('/login').then(() => {
    // Do something 
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related