【发布时间】:2018-09-25 18:30:53
【问题描述】:
我有一个主页组件,用户在导航栏中有登录选项。用户使用 gmail id 登录后,他被重定向到另一个组件。问题在于,路由不是替换组件,而是将组件堆叠在一起。
控制台中没有错误。
下面是我的 service.ts 代码:
import { Injectable } from '@angular/core';
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase} from 'angularfire2/database';
import * as firebase from 'firebase/app';
@Injectable({
providedIn: 'root'
})
export class AuthService {
constructor(public af: AngularFireAuth) {
}
loginWithGoogle() {
return this.af.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
}
logout() {
return this.af.auth.signOut().then(() => {
window.location.assign("https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://localhost:4200/");
})
}
}
登录和注销功能如下:
login() {
this.authService.loginWithGoogle().then((res) => {
this.router.navigate(['/explore']);
})
}
logout() {
this.authService.logout().then((res) => {
this.router.navigate(['/']);
})
}
我找不到任何解决方案,请帮助我!
【问题讨论】:
-
您能否创建一个 StackBlitz 来重现该问题?
-
在导航时检查控制台是否有错误。另请参阅this question。
-
@ConnorsFan 没有错误。
-
你是否有机会在 Angulars Zones 之外使用 ES6 Promises?
-
@PhilippMeissner 我不知道区域怎么样,抱歉!
标签: angular firebase login angular6 logout