我有一个功能可以检查用户是否已登录并重定向到适当的页面。
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.auth.afAuth.authState
.subscribe(
user => {
if (user) {
this.router.navigateByUrl('/filter');
} else {
this.router.navigateByUrl('/register');
}
},
() => {
this.router.navigateByUrl('/register');
}
);
});
第一次登录后,我想看到的页面不同于'/过滤器',所以我写这样的东西:
login() {
this.auth.login(this.credentials)
.then(() => this.router.navigate(['/youLogged'])
但是现在每次我登录时,我都被重定向到“ /过滤器”页面。 综上所述,当我运行该应用程序并登录后,我想立即重定向到“ / filter”页面,但是当我第一次登录时(我称为“ login”功能),我想重定向到“ / youLogged”页面。你知道如何实现吗?