主要代码
items: Observable<any[]>;
ionViewWillLoad(){
this.fire.authState.subscribe(data => {
if(data && data.email && data.uid){
this.toastCtrl.create({
message : ` welcome ${data.email}`,
duration:2000
}).present()
this.items = this.db.list('report').valueChanges();
}
})
}
html
<ul>
<li *ngFor="let item of items | async">
{{ item.title}}
</li>
</ul>
数据库
{
"report" : {
"8D3sENaBcLaXoGNnh1MPuoyj5LP2" : {//user id
"-LWzDSLtLzgY2wbtsLr5" : {
"name" : "test",
"title" : "test",
}
},
"WUM2HBkGo8TFDeOjEqO1s3lCj1p1" : { //user id
"-LWz7JClidqmWJcn4Qbt" : {
"name" : "check",
"title" : "chrck",
}
}
}
}
如果使用report/userid
,我只会得到我的帖子! ,我想按用户显示所有帖子