I'm trying to logout and then navigate to a login url, but the authguard from this url prevents logged users to view it and since the second line is reached before the promise is resolved you need to click the method event twice to make it work.
logout(){
this.angularfire.auth.logout();
this.router.navigate(['']);
}
Is there a way to implement router.navigate inside a callback when the promise is resolved? I've tried then(), but either my syntax was incorrect or there is a problem with auth typings...
AngularFire2's
logoutshould really behave in a manner similar to the underlying Firebase SDK. Fortunately, a few days ago, a PR was merged that changeslogoutto return a promise - so the next release will address your issue.Until then, you could listen to the
authchanges to determine when it's okay to navigate: