Created
January 4, 2018 16:16
-
-
Save javebratt/ac6cfe8178afc0b483aa5e4a6df53781 to your computer and use it in GitHub Desktop.
How to retrieve the guest list from an Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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