【发布时间】:2018-08-18 06:32:48
【问题描述】:
我目前正在使用前端框架 Ionic 和带有 typescript 的 angularjs 开发移动应用程序,而后端我使用的是 firebase。我的问题是,当我调用我的 firebase nosql 数据库时,我无法将我的项目放入 typescript 数组中以便将数据显示到屏幕上,因为当我调用包含值的变量时,它是未定义的。这是我的代码:
getSingleDatabase(){
this.collectionReference=this.db.collection('posts');
this.collectionReference.get()
.then(snapshot =>{
snapshot.forEach(doc => {
this.firstGet.push(doc.data());
});
})
.catch(err =>{
console.log(err);
});
return this.firstGet;
}
【问题讨论】:
标签: typescript firebase ionic-framework google-cloud-firestore