我使用过 ngInfiniteScroll 但我有一个小问题,我在变量项中有一组数据,例如)20,但我想在第一个视图中显示 5,其余的在滑动时显示。但是我的代码在第一个视图中加载了所有 20 我如何实现这一点,我在下面给出了我的代码和我的数据结构
{
"data": [ {
"name": "Hoarding Majestic",
"code": 456,
"image": "assets/images/images/hoarding1.jpg",
"location": "Majestic"
},
{
"name": "BusShelter ForumMall",
"code": 452,
"image": "assets/images/images/hoarding2.jpg",
"location": "Whitefield"
},
{
"name": "Digital Vijayanagar",
"code": 458,
"image": "assets/images/images/hoarding3.jpg",
"location": "Vijayanagar"
},
{
"name": "Digital Vijayanagar",
"code": 458,
"image": "assets/images/images/hoarding3.jpg",
"location": "Vijayanagar"
}
]
}
html:-
<div layout="row" layout-align="space-around" layout-padding infinite-scroll='loadMore()' infinite-scroll-distance='2'
infinite-scroll-disabled='{{busyLoadingData}}' infinite-scroll-container = "'#content'">
<table class="simple">
<thead>
<tr>
<th class="secondary-text">
<div class="table-header">
<span class="column-title">Asset</span>
</div>
</th>
<th class="secondary-text">
<div class="table-header">
<span class="column-title">Location</span>
</div>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="assets in items">
<!--| priceRange:slider:lower:upper-->
<td>{{assets.name}}</td>
<td>{{ assets.location }}</td>
</tr>
</tbody>
</table>
</div>
和我的控制器:-
$scope.data = booking.data;
$scope.busyLoadingData = false;
$scope.items = [];
$scope.loadMore = function() {
//console.log("asdfasdfasd");
if($scope.busyLoadingData)
return;
$scope.busyLoadingData = true;
var last = $scope.data[$scope.data.length - 1];
for(var i = 0 ; i <= 5; i++) {
$scope.items.push($scope.data[i]);
//console.log(last);
}
$timeout(function(){$scope.busyLoadingData = false; }, 3000 );
};