Listen for changes on data in Firebase (AngularFire)

1.5k views Asked by At

Is it possible to listen for Firebase server updates on the DOM in AngularFire?

I want to be able to fetch any updates when they are returned from the server to update the values of an array. Basically my problem is that I am using Firebase.ServerValues.TIMESTAMP which is set by the server.

Furthermore, why can't I use new Date() to create a client timestamp?

1

There are 1 answers

0
Frank van Puffelen On BEST ANSWER

You can extend the $firebaseArray and $firebaseObject specifically for that purpose. See https://www.firebase.com/docs/web/libraries/angular/guide/extending-services.html

When you call new Date() it creates a Date object, which is not a JSON type. If you're looking to store the current timestamp, you can get that by Date.now().