【发布时间】:2018-08-04 15:42:38
【问题描述】:
在我的 angular-app 中,我使用 angularfire2 身份验证。 打开某个窗口时,我想获取当前用户的邮箱。
为此,我写了如下代码:
ngOnInit() {
this.currentUserEmail = this.angularFireAuth.authState
.switchMap(user => {
console.log("this is a test");
return user.email;
});
}
代码遵循此处的文档: https://angularfirebase.com/lessons/google-user-auth-with-firestore-custom-data/#Step-3-Auth-Service
但是,由于某种原因,“switchMap”之后的部分从未输入过”。 所以“这是一个测试”这一行永远不会被打印出来。
如何获取当前用户(和他/她的电子邮件)?
【问题讨论】:
标签: angular firebase firebase-authentication angularfire2