如何在angularJS中为嵌套的for循环实现nginfiniteScroll



我一次获取整个后端数据,并在迭代时迭代该数据,同时调用另一个API将一些信息添加到第一个迭代对象中,并将其推送到另一个Array 中

$scope.pdetails=[];
propertyService.getPropertyData().success(function(ProObj){ // whole data from backend
$scope.pdetails=ProObj;
ProObj.forEach(function(PhotoId){
var photos=[];
PhotoId.photosId.forEach(function(Pid){
profileService.fetchProfileImage(Pid)  //calling another API here
.success(function(image){
photos.push(image);
})
})
ProObj.photos=photos;
$scope.pdetails.push(ProObj); //final Array
})
})

在应用程序中,在视图中显示内容花费了很长时间,因此我想使用nginfiniteScroll每次滚动加载5个对象如何做到这一点任何人都可以帮助我

$scope.pdetails=[];
propertyService.getPropertyData().success(function(ProObj){ 
$scope.pdetails=ProObj;
angular.forEach(ProObj,function(key,PhotoId){
if(key<4){
var photos=[];
angular.forEach(PhotoId.photosId,function(key,Pid){
profileService.fetchProfileImage(Pid)
.success(function(image){
photos.push(image);})
})
ProObj.photos=photos;
$scope.pdetails.push(ProObj);
})
}
})

最新更新