Firebase 使用angularfire/collection同步相关数据
我想使用angularfirecollection与数据列表保持单向同步。该结构是一个具有各种属性(例如“like”)的“things”列表,以及每个用户都持有“things”键的子集(例如-jsdzdsrestofkey:true)。U 通过使用angularfirecollection(或firebase native“on”),我可以同步特定用户拥有的所有内容。。。我还可以抓取(使用firebase native“一次”)每个“东西”的属性来显示 然而,在angular中,我需要使用$apply()将属性数据注入到用户“thing”列表中每个项目的范围中。为了保持同步,我想我可以使用firebase的on change事件。。。但这一切都需要我为用户列表中的每件事创建新的引用 在firebase中获取关系数据,同时保持列表和关系数据同步的最佳方法是什么 谢谢!Firebase 使用angularfire/collection同步相关数据,firebase,angularfire,Firebase,Angularfire,我想使用angularfirecollection与数据列表保持单向同步。该结构是一个具有各种属性(例如“like”)的“things”列表,以及每个用户都持有“things”键的子集(例如-jsdzdsrestofkey:true)。U 通过使用angularfirecollection(或firebase native“on”),我可以同步特定用户拥有的所有内容。。。我还可以抓取(使用firebase native“一次”)每个“东西”的属性来显示 然而,在angular中,我需要使用$ap
Irfaan如果我理解正确,听起来您应该使用索引并将其直接输入
angularFireCollection
。这样您就不需要使用$apply
,因为东西
数据已经在$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
非常感谢。在发布之前,我在搜索中遇到了Firebaseindex,但在上面的问题中忘记了提及它。这是唯一的解决办法吗?firebase或angularfire没有原生的东西吗?对于这个确切的用例,我认为它是“原生的”;如果我没有弄错的话,Firebase索引是由Firebase团队维护的。为了将来的参考,Firebase团队现在正在开发一个用于join/etc的官方库。