我正在嘗試從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結構 –