为什么我从数据库中获取空数据html

时间:2019-01-24 09:51:49

标签: firebase firebase-realtime-database ionic3 angularfire2

我正在尝试从Firebase数据库中获取数据,并且想为所有用户而不是一个用户显示一份报告列表。我尝试使用下面的代码,但是我得到了空页!

主要代码

 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",
      }
    }
  }
}

enter image description here

如果使用report/userid,我只会得到我的帖子! ,我想按用户显示所有帖子

0 个答案:

没有答案
相关问题