Andreas Selenwall
Andreas Selenwall

Reputation: 5775

Listen for changes on data in Firebase (AngularFire)

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?

Upvotes: 0

Views: 1538

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

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().

Upvotes: 2

Related Questions