首先是代码
var baseRef = new $databaseFactory();
var childRegistration = baseRef.child("registrations/");
var childStudents = baseRef.child("students/");
$scope.scrollRef = new Firebase.util.Scroll(childRegistration,'registerDate');
var normRegisteredStudens = new Firebase.util.NormalizedCollection(
[childStudents, "student"],
[$scope.scrollRef, "registration"]
).select(
"student.id",
"student.avatarImg",
"registration.registerDate",
"registration.entryMethod"
).ref();
$scope.lastRegisteredStudents = $firebaseObject( normRegisteredStudens );
$scope.loadRegisteredStudents = function() {
$scope.scrollRef.scroll.next(1);
};
数据结构
"registrations" : {
"STD32159500" : {
"entryMethod" : "web",
"registerDate" : 1447425200913
},
"STD32159501" : {
"entryMethod" : "web",
"registerDate" : 1447430433895
}
"students" : {
"STD32159500" : {
"avatarImg" : "students/default-avatar-male.png",
"id" : "STD32159500",
},
"STD32159501" : {
"avatarImg" : "students/default-avatar-female.png",
"id" : "STD32159501",
}
没有错误,但我仍然没有使用“loadRegisteredStudents”函数逐个注册值,而不是那样,我得到了所有结果。
我在加载网站上看到这个
STD32159500:
avatarImg: "students/default-avatar-male.png"
entryMethod: "web"
id: "STD32159500"
registerDate: 1447425200913
STD32159501:
avatarImg: "students/default-avatar-female.png"
entryMethod: "web"
id: "STD32159501"
registerDate: 1447430433895