Skip to content

Instantly share code, notes, and snippets.

@javebratt
Created January 4, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javebratt/ac6cfe8178afc0b483aa5e4a6df53781 to your computer and use it in GitHub Desktop.
Save javebratt/ac6cfe8178afc0b483aa5e4a6df53781 to your computer and use it in GitHub Desktop.
How to retrieve the guest list from an Event
// First I would create a function in the EventProvider to fetch the guest list
getGuestList(eventId: string): firebase.database.Reference {
return this.eventListRef.child(eventId).child('guestList');
}
// Then I'd call it from the event's detail page:
public guestList;
ionViewDidLoad(){
...
this.eventProvider.getGuestList(this.navParams.get('eventId'))
.on('value', eventListSnapshot => {
this.guestList.push(eventListSnapshot.val());
});
}
// Then you can fetch the guest list from the HTML page, something like this:
<ion-list>
<ion-item *ngFor="let guest of guestList">
<ion-avatar item-start>
<img [src]="guest.profilePicture">
</ion-avatar>
<h2>{{ guest.guestName }}</h2>
</ion-item>
</ion-list>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment