我是Angular-Firebase開發的新手,我在理解如何檢索嵌套在兩個集合中的數據時遇到問題。 我有一個名爲「訂單」的集合,其中包含一個字段調用「auth」,這是用戶ID,我有另一個集合是「用戶配置文件」,它的$ id是「auth」的值。在用戶配置文件中,我有一個名爲roomNumber的字段,它的內容是我每次讀取時都要檢索的內容,以ng-重複訂單。如何檢索嵌套在兩個集合從角落的火力基地
在我看來,我試圖做這樣的事情:
<tr ng-repeat="item in items | filter: searchKeyword ">
<td align="left">{{item.$id}} - {{roomNumber(item.$id)}}</td></tr>
roomNumber是一個函數在我的控制器
$scope.roomNumber = function(id) {
var rootRef = new Firebase("https://xxxx-fire-yyyy.firebaseio.com/userProfile"+ '/' + id);
$scope.userdet = $firebaseArray(rootRef);
rootRef.on("value", function(rootSnapshot) {
var key = rootSnapshot.key();
var childKey = rootSnapshot.child("room").val();
console.log("room ", childKey)
});
return childKey
}
當我運行此代碼,請參閱我的js控制檯的結果,奇怪的事情發生: 1.它重複很多次 2.我永遠不可能得到childKey值
我一直在讀F irebase文檔,但我真的不明白如何做這個「愚蠢」的事情,有沒有人給我一個如何做到這一點的小費?
它的另一個firebase數據集合 – CaribeSoft