【发布时间】:2018-10-09 02:40:34
【问题描述】:
我在使用 Auth 创建用户后尝试访问 firebase 数据库,但没有成功。 使用 Auth 创建用户后,我想将其保存在实时数据库中并添加更多字段。
signUpBrother(email: string, password: string) {
this.fireAuth.auth.createUserWithEmailAndPassword(email, password)
this.fireAuth.auth.onAuthStateChanged(function(user) {
this.firebase.list('brothers').set(uid, {
'email': user.email,
'nickname': 'nickname',
'avatar': 'avatar',
'is_big_brother': true
})
})
}
我得到的错误是:
错误错误:未捕获(承诺中):TypeError:无法读取未定义的属性“firebase”
感谢您的帮助!
【问题讨论】:
-
thisonAuthStateChanged 内部的对象与您期望的不同。在 onAuthStateChanged 之前执行var _this = this;之类的操作,然后在回调中使用变量
标签: javascript angular firebase firebase-realtime-database firebase-authentication