Reputation: 386
My firebase database is called verhuurfietsen and I have a maximum amount of 4 which I want to get and set but still the maximum has to be 4.
obj;
constructor(private db: AngularFireDatabase){}
ngOnInit() {
this.obj = this.db.database.ref('amount');
}
updateMaxValue(){
this.obj.update(this.max)
}
pushing is not an issue but I can't seem to find anywhere how you get a single value out of a firebase database. I want to initialise my max
variable with the valure from the firebase db
Upvotes: 0
Views: 1220
Reputation: 6900
Try in Angularfire2 way
ngOnInit() {
this.db.object('amount').valueChanges().subscribe(action => {
console.log(action);
for(var obj in action) {
console.log(obj);
this.max = Number.parseInt(obj);
}
});
}
Upvotes: 1