我想从指定用户的Firebase获取用户配置文件数据。通过实例,我想返回UID HBJKD12345所在的用户的displayName和电子邮件地址
我使用这个功能:
this.userProfile = this.af.database.object('/users/'+this.authInfo.uid)
但是有了一个console.log(this.userProfile.email)
我得到“未定义”
在我看来,我必须使用:{{(userProfile | async )?.email}}
在这一行中,我可以显示用户的电子邮件地址,但是当我尝试使用console.log时为什么会显示“ Undefined”(未定义)?
由于,您的视图起作用async
。它解开了实际值。对于console.log()
,您需要执行类似的操作。尝试一下this.userProfile.$value()
。
看看https://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md#meta-fields-on-the-object或https:// github。 com / angular / angularfire2 / blob / master / docs / 2-retrieving-data-as-objects.md#meta-fields-on-the-object
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句