NicoleZ
NicoleZ

Reputation: 1780

AngularFire2 Retrieve Child node Data As Object

I want to retrieve data in child node as a Object using angularfire2

     getPostEditData(uid:any,key:any){

     this.dataObject = this.af.database.object('/webPosts/'+uid+key) as 
     FirebaseObjectObservable<postVal>
     return this.dataObject; }

I used this but its not working. How I suppose to do that? My Structure

Upvotes: 0

Views: 494

Answers (1)

theblindprophet
theblindprophet

Reputation: 7947

You need another slash (/) with your reference.

getPostEditData(uid:any,key:any) {
    this.dataObject = 
        this.af.database.object('/webPosts/' + uid + '/' + key) as FirebaseObjectObservable<postVal>
    return this.dataObject; 
}

Wrong: uid + key

Right: uid + '/' + key

Upvotes: 2

Related Questions