in an ionic2 project with angularfire2 + firebase I am trying to transform the data out of the firebase table into something usable in the .ts file.
that works:
in .ts
this.list = af.database.list('/items');
in html
*ngFor="let item of list | async"
This give me all objects to use with {{item.val}} However, I want to use this data directly in the script instead of viewing so I am trying to access it by variables with subscribe in typescript. this is the current approach and
that doesnt work:
this.af.database.list('/items/', { preserveSnapshot: true } )
.subscribe(snapshots =>
{
snapshots.forEach(snapshot =>
{
if ( !someList.some(x=>x==snapshot.key) )
{
someList.push(snapshot.key);
console.log(snapshot.val());
this.af.database.object('/items/'+snapshot.key, { preserveSnapshot: true } )
.subscribe( item =>
{
console.log(item.val();
});
}
})
});
It logs [object Object] for each item in the console.
I dont get how I get to the content of either [object Object] returned by the observables without touching html, best case as easy as item.value?
I found some examples with .map which returns for me TypeError: item.map is not a function.
How to get to the content of those objects?
Any help or hints to test are appreciated Thank you