Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular router: promise returned from navigatebyurl is ignored

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.

like image 329
Sammy Avatar asked May 20 '17 11:05

Sammy


1 Answers

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

this.router.navigateByUrl('/login').then(() => {
    // Do something 
});
like image 196
Amir BenAmara Avatar answered Oct 24 '22 05:10

Amir BenAmara