2

I'm going to retrieve a list from Firebase using the following code in an Ionic component:

this.afDB.list ( '/my-data/key1/data' ).valueChanges().subscribe ( res => console.log (res), error => console.log (error), () => console.log ("complete") );

if the record exists, it has no problem to print the result. However, if the record does not exist, none of the three callbacks will return. If I replace the list() with object() method, it will simply return null, which is what I need. Does anyone know if this is the intent by design of AngularFire 5 or it's a bug?

David
  • 21
  • 1
  • 2

2 Answers2

2

There is currently a bug in angularfire. https://github.com/angular/angularfire2/issues/1220

Benny
  • 258
  • 1
  • 4
  • 11
0

With ionoc 3 framework, some of mine dependencies are like these in the package.json file:

"angularfire2": "^5.0.0-rc.11",
"firebase": "^5.0.4",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.1",

And this works for me:

this.afs.list("marker").valueChanges().subscribe( (data: any) => {
    data.forEach(item => {
      console.log("Lat: "+item.lat+" Lng: "+item.lng)
    }
});
Harry
  • 1,147
  • 13
  • 13