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不是一个函数” –