0
我想記錄'Checker'的值(布爾值),但總是返回'undefined'。我的代碼如下:在控制檯上AngularFire2,snapshot.val返回undefined
loginUser(key: string, Checker: boolean) {
if (!this.loginForm.valid) {
*doesn't matter*
} else {
*doesn't matter*
...
var checked = this.af.object('/Users/' + key,
{preserveSnapshot: true});
checked.subscribe(snapshot => {
console.log(snapshot.key);
console.log(snapshot.val.Checker);
});
}
輸出是:
*key*
*undefined*
'val'是一個函數:'snapshot.val()。Checker' – cartant
https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot#val – cartant
@cartant - 如果我確實那它返回「snapshot.val不是一個函數」 –