Angularfire无法在signInWithPopup()后重定向

Angularfire无法在signInWithPopup()后重定向,angular,firebase,firebase-authentication,angularfire2,Angular,Firebase,Firebase Authentication,Angularfire2,使用Angular2和angularfire2,我尝试在用户使用“signInWithPopup”功能登录google后重定向用户,一旦用户登录页面,立即刷新并加载首页,但我希望在登录后将用户重定向到其他页面 下面的代码是用户登录google的功能 loginWithGoogle() { return this.authentication.auth .signInWithPopup(new firebase.auth.GoogleAuthProvider());} 下面的代码是试图让用

使用Angular2和angularfire2,我尝试在用户使用“signInWithPopup”功能登录google后重定向用户,一旦用户登录页面,立即刷新并加载首页,但我希望在登录后将用户重定向到其他页面

下面的代码是用户登录google的功能

 loginWithGoogle() {
return this.authentication.auth
  .signInWithPopup(new firebase.auth.GoogleAuthProvider());}
下面的代码是试图让用户登录的函数,调用上面的函数

loginWithGoogle() {
this.authentication.loginWithGoogle().then(function (result) {
  this.router.navigate(['/exampleRoute']);
}).catch(function (error) {
  alert('error');
});}

当用户根据firebase文档通过弹出窗口登录时,一旦登录完成,函数中的任何内容都应该发生,但它只是重定向到“/”路由。值得注意的是,一旦用户使用popup登录,我认为页面会刷新,这意味着它只是重新加载到第一条路径。使用箭头函数,而不是我试图告诉它转到的位置。

您已经失去了上下文:

this.authentication.loginWithGoogle().then((result) => { 
  if(result.uid !== null) {
    this.router.navigate(['/exampleRoute'])
  }
})

您已丢失的上下文,请使用箭头函数:

this.authentication.loginWithGoogle().then((result) => { 
  if(result.uid !== null) {
    this.router.navigate(['/exampleRoute'])
  }
})

将其更改为箭头表达式似乎根本不会改变其工作方式,如果我尝试调用警报,警报不会调用,但如果我将数据记录到控制台,它正在记录,但仍然重定向到“/”页面。您如何导入firebase auth(
firebase.auth
)?“导入{AngularFireAuth}”从'angularfire2/auth';从'firebase/app'导入*作为firebase;“这就是我导入firebase功能的方式。将其更改为箭头表达式似乎根本不会改变其工作方式,如果我尝试调用警报,警报不会调用,但如果我将数据记录到控制台,它将记录,但仍重定向到“/”页面。您如何导入firebase auth(
firebase.auth
)?“从'angularfire2/auth'导入{AngularFireAuth};从'firebase/app'导入*作为firebase;”这就是我导入firebase功能的方式。