retrieve list by id from firebase angular 1

retrieve list by id from firebase angular

this.itemsRef = db.list('messages');
// Use snapshotChanges().map() to store the key
this.items = this.itemsRef.snapshotChanges().map(changes => {
  return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});

Here is what the above code is Doing:
1. We’re creating a FirebaseListObservable of Message objects.
2. We’re using snapshotChanges() to get the key and value of each message.
3. We’re mapping the list to return an array of Message objects.

Similar Posts