【发布时间】:2016-12-10 04:39:21
【问题描述】:
我正在开发一个 Ionic2 应用程序并且我正在使用 Promise。在 Typescript 类中,我创建了这个方法
tapOnRegistrati() {
this.authService.userRegistration(this.email,this.password).then(function(user){
this.user = this.af.database.object('/users/' + user.uid);
this.user.set({ name: this.name, lastname: this.lastname});
}).catch(function(error: any) {
});
}
但是当then 块被执行时this 的引用是null,所以我不能使用我的打字稿类的任何对象/属性。为什么?
【问题讨论】:
标签: angular firebase firebase-realtime-database ionic2