【发布时间】:2019-08-20 20:58:06
【问题描述】:
好的,我在尝试从 Firestore 中的集合返回数据时遇到错误。
错误错误:未捕获(承诺中):TypeError:无法读取未定义的属性'get'
错误指向这里的.get()
ngOnInit() {
this.noteService
.getNoteList()
.get()
.then(noteListSnapshot => {
this.noteList = [];
noteListSnapshot.forEach(snap => {
this.noteList.push({
id: snap.id,
noteBottle: snap.data().noteBottle,
noteDistillery: snap.data().noteDistillery,
noteDate: snap.data().noteDate,
});
return false;
});
});
}
我认为问题确实在我的服务中,但看起来像这样......
public noteListRef: firebase.firestore.CollectionReference;
public currentUser: firebase.User;
constructor() {
firebase.auth().onAuthStateChanged(user => {
if (user) {
this.currentUser = firebase.auth().currentUser;
this.noteListRef = firebase.firestore().collection(`/userProfile/${this.currentUser.uid}/eventList`);
}
});
}
关于为什么 get 未定义的任何想法?
【问题讨论】:
标签: angular firebase ionic-framework google-cloud-firestore