I have the following snippet
This is my main.html
<h2 class="txtcenter po-2text" style="padding-top:30px">
{{title}}
</h2>
This is my main.ts:
title: string;
ngOnInit() {
var self = this;
var ref = firebase.database().ref('schools/' + this.currentUserId());
ref.orderByChild('title').on('value', function(dataSnapshot) {
console.log("Title is: " + dataSnapshot.val().title);
self.title = dataSnapshot.val().title;
});
}
Even though the callback gets fired with some valid data, the title doesn't update automatically. What am I missing?
Any help is appreciated!
ngOnInitlike this:ngOnInit() { const ref = firebase.database().ref('schools/' + this.currentUserId()); ref.orderByChild('title').on('value', dataSnapshot => this.title = dataSnapshot.val().title); }console.logworks fine?console.logworks fine