【发布时间】:2017-12-22 03:44:40
【问题描述】:
我正在尝试创建一个帖子评论关系,用户可以写帖子,其他用户可以评论帖子。
我可以显示帖子,但是在尝试加入以显示属于帖子的 cmets 时,我无法.. 下面是我的数据库架构
我在想,首先我需要从帖子节点获取密钥,然后移动到 cmets 并以某种方式获取每个帖子的 cmets.. 并在帖子的 ngfor 内的 *ngfor 中使用它?
我正在尝试类似的东西
findAllComments(){
this.db.list('posts', { preserveSnapshot: true})
.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
return this.db.list(`comments/${snapshot.key}`)
});
});
}
但这当然返回无效:
当我 console.log:
findAllComments(){
this.db.list('/posts', { preserveSnapshot: true})
.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
const kapa = this.db.list(`comments/${snapshot.key}`).do(console.log)
kapa.subscribe();
});
});
}
我进入控制台
我不确定我的想法是否正确。
我很困惑,因为我是 angular 和 firebase 的新手。
【问题讨论】:
标签: javascript angular firebase firebase-realtime-database angularfire2