【发布时间】:2017-05-16 03:31:09
【问题描述】:
我有一个 Firebase 对象,如下所示:
-notifications
-1-1-2017 1:08:22 PM
-message: 'test'
-timestamp: 1483294112
-1-1-2017 1:08:23 PM
-message: 'two'
-timestamp: 1483294113
-1-1-2017 2:08:22 PM
-message: 'three'
-timestamp: 1483294473
我不断将新属性推送到notifications 对象中,其中键是日期时间。
如果我有如下所示的$watch,如何获取附加到notifications 对象的最新属性?
var ref = new Firebase(firebaseConstants.url + 'notifications');
var sync = $firebase(ref);
$scope.notifications = sync.$asArray();
$scope.$watch('notifications', function(){
......
});
我想避免在$scope.notifications 上运行循环来找出新旧值之间的差异。
Firebase JS API 或 AngularFire 库是否有内置方式来执行此操作?
【问题讨论】:
标签: firebase firebase-realtime-database angularfire