我能够获取Firebase用户的自定义详细信息,例如城市移动电话等。并在控制台中将其打印出来。我想将它们分配给对象/字符串,以便可以使用.html在浏览器中显示。
我尝试使用AngularFireList等...但无法正常工作。
getDetails() {
var user = firebase.auth().currentUser;
if (user) {
var getUserInfo = firebase.database().ref("users/" + user.uid);
return getUserInfo.once("value")
}
else{
return null;
}
}
component.ts
city:any;
mobile:any;
ngOnInit(){
this.auth.getDetails().then(function(snapshot) {
snapshot.forEach((child) => {
this.childs.push({
city:child.val().city,
mobile:child.val().mobile,
})
});
})
}
.html
<div class="container">
<p> {{city}}
{{mobile}}</p>
</div>
每当我尝试分配给任何对象时,它就会显示为“无法设置属性”等。