2
我試圖爲我的angularjs應用程序實現無限滾動。結識ngInfiniteScrollngInfiniteScroll中的瀏覽器滾動時未調用loadMore()
我使用他們的demos
頁給出同樣的例子的使用。它不是爲我工作,
profile.ejs:
<script src='../controllers/jquery.min.js'></script>
<script src='../controllers/angular.min.js'></script>
<script src='../controllers/ng-infinite-scroll.min.js'></script>
<!-- some other code -->
<ul infinite-scroll='loadMore()' infinite-scroll-distance='1' >
<div ng-repeat="item in images">Item number {{$index}}: {{$item}}</div>
</ul>
<!-- some other code -->
profileController.js
$scope.images = [1, 2, 3, 4, 5, 6, 7, 8];
$scope.loadMore = function() {
alert("called");
var last = $scope.images[$scope.images.length - 1];
for(var i = 1; i <= 2; i++) {
$scope.images.push(last + i);
}
};
的alert("called")
不會被調用瀏覽器的滾動。任何人都可以幫助我解決我的錯誤,或者我怎樣才能實現無限滾動?
您可能在模塊和控制器聲明中缺少某些內容,請確保您遵循以下鏈接中的所有步驟:http://4dev.tech/2015/08/tutorial-implementing-infinite-scroll-with-angularjs -and-nginfinitescroll / –