我正在尝试从firebase读取值并将其分配给全局变量,但它无效。如何将从firebase读取的值赋给变量
public points: any;
readPoints(): any{
this.userProfile.child(this.user.uid).once('value').then((snapshot) =>{
this.points = snapshot.val().user_points;
});
}
console.log(this.points); //undefined
Users{
SAdS4cW57DSLuWr2obbZYUHsmAL2{
user_points: 20
.....
可以更新你与你的数据库结构为例问题吗? –
我加了db结构 –