0
我開始在離子與火力的發展和我面對一點憂慮。這是我的數據庫。我想顯示用戶X是其成員的所有房間。在每個組中都有一個表格用於列表成員。但我可以列出所有的房間。用離子查詢Firebase
"rooms" : {
"-Kq-SLPGXoyW5bn8384X" : {
"createdAt" : 1501098764132,
"group_dp" : "img_base64",
"groupname" : "PDCI",
"members" : [ "10", "11", "12" ],
"ownerId" : "10",
"type" : "groupe"
},
"-Kq-StfFDhhuOgMhNrae" : {
"createdAt" : 1501098908584,
"group_dp" : "img_base64",
"groupname" : "Echo",
"members" : [ "10", "13", "14", "15", "16", "17", "18" ],
"ownerId" : "10",
"type" : "onetoone"
}
}
function Rooms($firebaseArray, UserService, firebase, $localStorage, $sessionStorage) {
var currentUser = UserService.getProfile();
var ref = firebase.database().ref();
var rooms = $firebaseArray(ref.child('rooms'));
return {
all: function() {
rooms.$loaded().then(function(response) {
console.log(response);
angular.forEach(response, function(room) {
ref.child('room-messages').child(room.$id)
.orderByChild("createdAt")
.limitToLast(1)
.on("child_added", function(snapshot) {
room["last_message_content"] = snapshot.val().content;
});
})
});
return rooms;
}
OKay謝謝我試試。 –