我试图让 ngInfiniteScroll 工作,但徒劳无功 - Plunker。滚动事件仅在页面加载时触发,之后似乎没有触发它。任何人都可以请阐明一些光。
我尝试了各种组合,都没有奏效:
infinite-scroll='loadMore()' infinite-scroll-distance='2' infinite-scroll-container="'#list-wrapper'"
infinite-scroll='loadMore()' infinite-scroll-distance='2' infinite-scroll-parent
infinite-scroll='loadMore()' infinite-scroll-distance='2'
HTML:
<body ng-app="app" ng-controller="listController">
<div id="list-wrapper">
<div class="list" infinite-scroll='loadMore()'
infinite-scroll-distance='2'
infinite-scroll-container="'#list-wrapper'">
<div class="header">
</div>
<div class="list-table" >
<table class="table">
<tbody>
<tr ng-repeat="item in infiniteList">
<td style="width:100%">
<div>{{item}}</div>
</td>
</tr>
</tbody>
</table>
</div>
<div style='clear: both;'></div>
</div>
</div>
JS:
var app = angular.module("app", ['infinite-scroll']);
app.controller('listController', ['$scope','$http', function ($scope,$http) {
$scope.infiniteList = [];
$scope.incr = 1;
$scope.loadMore = function(){
console.log("scroll");
for(var i = 0; i< 30; i++){
$scope.infiniteList.push("Item " + $scope.incr);
$scope.incr +=1;
}
};
}]);