0

我想使用 angularfirecollection 与数据列表保持单向同步。该结构是具有各种属性的“事物”列表(例如“喜欢”)和每个持有“事物”键子集的用户(例如 -jsdzsdrestofkey: true)。ü

唱 angularfirecollection(或 firebase native 'on'),我可以同步特定用户拥有的所有东西......我还可以抓取(使用 firebase native 'once')每个 'thing' 的属性来显示。

但是,在 Angular 中,我需要使用 $apply() 将属性数据注入到用户“事物”列表中每个项目的范围内。为了保持同步,我想我可以使用 firebase 的 on change 事件……但这一切都需要我为用户列表中的每个事物创建新的引用。

在保持列表和关系数据同步的同时,在 firebase 中获取关系数据的最佳方法是什么?

谢谢!伊尔凡

4

1 回答 1

0

如果我理解正确,听起来您应该使用FirebaseIndex并将索引直接输入到angularFireCollection. 然后你就不需要使用$apply了,因为thing数据已经在 中$scope,并且一切都将保持同步:

var index = new FirebaseIndex(fb.child('users/789/thing_list'), fb.child('things'));
$scope.things = angularFireCollection(index);
// $scope.things will contain the user's things with the associated thing data
于 2013-10-27T21:15:16.303 回答