Angularjs 基于另一个$firebaseobject的数据访问$firebaseobject的数据
我在Firebase上有以下结构Angularjs 基于另一个$firebaseobject的数据访问$firebaseobject的数据,angularjs,firebase,angularfire,Angularjs,Firebase,Angularfire,我在Firebase上有以下结构 +Groups -group1 -groupMessage: abc -groupName: xyz -members -User1 = STATUS: "true" -User2 = STATUS: "pending" +group2 +group3 etc.. +Users -User1 -Groups -group1 = STATUS: "true" -g
+Groups
-group1
-groupMessage: abc
-groupName: xyz
-members
-User1 = STATUS: "true"
-User2 = STATUS: "pending"
+group2
+group3
etc..
+Users
-User1
-Groups
-group1 = STATUS: "true"
-group3 = STATUS: "pending"
etc..
+User2
+User3
etc..
我正在尝试根据用户的状态是“真”还是“待定”,向个人用户显示组信息。我的应用程序有“待定”和“真实”状态的单独页面视图
下面是我如何努力做到这一点
.controller('GroupCtrl', function($scope, $firebaseObject, $rootScope) {
// Get a reference to the Firebase account
var fbRef = new Firebase("https://####.firebaseio.com/");
// Get a reference to where the User's Group IDs are stored
var fbUserCircle = new Firebase(fbRef + "/Users/" + $rootScope.fbAuthData.uid + "/Groups/");
var fbCircles = new Firebase(fbRef + "/Groups/");
var obj = $firebaseObject(fbUserCircle.orderByChild("Status").equalTo("pending"));
obj.$loaded().then(function() {
console.log("loaded record:", obj.$id);
// Iterating the key/value pairs of the object
angular.forEach(obj, function(value, key) {
var groupObj = $firebaseObject(fbCircles.child(key));
console.log("$ref: " + circlesObj.$ref());
circlesObj.$loaded().then(function() {
circlesObj.$bindTo($scope, "groups");
})
})
})
})
在我的页面视图中,我试图为具有“挂起”状态的组的用户显示{{groups.groupName}
和{{groups.groupMessage}}
overng repeat
“我的视图”中没有显示任何数据,用于显示具有“挂起”状态的用户组。我做错了什么?有谁知道更好的方法吗?这不是最好的方法吗?另外,对集合使用$firebaseArray,而不是$firebaseArray。@Kato根据您的评论,我尝试了以下方法:
fbUserCircle.orderByChild(“Status”).equalTo(“pending”).on('child_added',function(indexSnap){var query=fbCircles.orderByChild(“groupID”).equalTo(indexSnap.key());$scope.circles=$firebaseArray(query);})代码>仅在我的视图中加载集合中的最后一条记录,其余记录不显示。我错过什么了吗?