我想获取firebase中的项目列表,但项目的每个元素都有一个相关项目列表.我无法获得列表,既没有使用firebase-util也没有使用firebase数组扩展功能.
我的firebase数据看起来像这样:
items
item1
name: "Item 1"
user: user1
images
image1: true
image2: true
item2
name: "Item 2"
user: user1
images:
image3: true
image4: true
item3
name: "Item 3"
user: user2
images:
image5: true
image6: true
users
user1
name: "User 1"
email: "user1@email.com"
user2
name: "User 2"
email: "user2@email.com"
images
image1
image: "data:image/jpeg;base64,/9j/..."
thumb: "data:image/jpeg;base64,/9j/..."
image2
image: "data:image/jpeg;base64,/9j/..."
thumb: "data:image/jpeg;base64,/9j/..."
image3
image: "data:image/jpeg;base64,/9j/..."
thumb: "data:image/jpeg;base64,/9j/..."
image4
image: "data:image/jpeg;base64,/9j/..."
thumb: "data:image/jpeg;base64,/9j/..."
image5
image: "data:image/jpeg;base64,/9j/..."
thumb: "data:image/jpeg;base64,/9j/..."
Run Code Online (Sandbox Code Playgroud)
我只想获得包含所有数据的项目列表.就像是: …
我正在使用Firebase/AngularFire构建一个Ionic App.我面临着一个棘手的问题:我希望我的ng-repeat能够更好地进行性能优化.我听说最好的方法就是无限滚动.我使用AngularFire在服务/工厂中获取所有数据 - 更具体地说,$ firebaseArray.
我谷歌发现了这个:http://firebase.github.io/firebase-util/#/toolbox/Paginate/example/ionic
问题1:使用Firebase util库的无限滚动是无限滚动服务器端无限滚动还是客户端?这个库是否解决了ng-repeat的性能问题,如下所述:(http://www.alexkras.com/11-tips-to-improve-angularjs-performance/)
问题2:我的firebaseArray实际上需要命令动态计算一个名为distance的变量.我是否仍可以在安全规则中使用.indexOn规则来提高查询性能?(声音不可能,因为距离最初没有存放在火场中)
这是我的代码:我的工厂:taskService.js
var ref = new Firebase(FirebaseUrl);
var tasks = $firebaseArray(ref.child('tasks'));
var Task = {
all: tasks,
getAllTasks: function() {
if (tasks.length == 0) {
tasks = $firebaseArray(ref.child('tasks'));
} else {
tasks = tasks;
}
return tasks;
},
}
Run Code Online (Sandbox Code Playgroud)
我的ng-repeat视图控制器:
$scope.tasks = taskService.getAllTasks();
$scope.tasks.$loaded().then(function(data){
calculateDistance($scope.tasks, $scope.userCurrentLocation);
});
var unwatch = $scope.tasks.$watch(function(event) {
calculateDistance($scope.tasks, $scope.userCurrentLocation);
});
$scope.$on('$ionicView.leave', function(){
// Anything you can think of
unwatch();
});
}
//--------------GeoLocation …Run Code Online (Sandbox Code Playgroud)