0

Hoping someone can point me into the right direction.

I'd like to be able to map item details to the items list observable so that it can be access by item.details as shown in the third section below.

It's not important that the 'itemDetails' are observable, as they're unlikely to change.

{
  "items": {
    "1111": {
      "count": 5
    },
    "2222": {
      "count": 4
    }  
  },
  "itemDetails": {
    "1111": {
      "title": "a title"
    },
    "2222": {
      "title": "another title"
    }
  }
}

items: FirebaseListObservable<any>;

ngOnInit() {
  this.items = this.db.list("items");
}

<some-elem *ngFor="let item of items | async">
        {{item.details | json}}
</some-elem>
AshClarke
  • 2,990
  • 5
  • 21
  • 27
  • 1
    I've seen a few questions on such joins: https://stackoverflow.com/questions/41755579/how-to-get-do-a-join-in-angularfire2-database, https://stackoverflow.com/questions/40999531/how-to-join-two-nodes-with-angularfire2-and-firebase – Frank van Puffelen Jul 13 '17 at 00:26

1 Answers1

0

My solution is:

this.items = this.db.list('items')
  .map(itemEntries => {
    itemEntries.map(itemEntry => {
      itemEntry.details = this.db.object(`itemDetails/${itemEntry.$key}`)
   })
   return itemEntries;
 })

hope that helps someone

AshClarke
  • 2,990
  • 5
  • 21
  • 27