-
-
Save gustavo-depaula/24ff69bb4810faf6db13c3fbc71602ef to your computer and use it in GitHub Desktop.
Rate iPoo
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
ratesRef: AngularFireList<any> | |
rates: Observable<any[]> | |
constructor ( db: AngularFireDatabase ) { | |
this.ratesRef = db.list('bathrooms') | |
// Use snapshotChanges().map() to store the key | |
this.rates = this.ratesRef.snapshotChanges().map(changes => { | |
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() })) | |
}) | |
alert(this.rates) | |
} | |
getRates () { | |
return this.rates | |
} | |
getRatesByBathroom (bathroomKey) { | |
return this.rates.filter(rate => rate.bathroomKey === bathroomKey) | |
} | |
addRate (data) { | |
this.ratesRef.push(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment