angularionic3observableangularfire5

How to Render Single Observerble Data in HTML ionic 3


I use Observable to get single object data from the firebase. How do I render this data on HTML? I use this {{(postObservable2|async)?.subject}} but nothing is rendered.
I tried to use AngularFireObject as well but it keeps throwing an error saying that

firebase datasnapshot type cant assign to the AngularFireObject.


"angularfire2": "^5.0.0-rc.4"

 this.postObservable = this.firebase.object(`allPosts/${this.postID}`).snapshotChanges();

Solution

  • Try subscribing to the observable this way:

    let yourArray = [];
    this.postObservable.subscribe(res => {
      res.map(c => {
        yourArray.push(c);
      })
    })
    console.log(yourArray);
    

    Then in the template use yourArray as ngFor iteratable.