|
求问大神,我这边配置了ion-infinite-scroll,但是每次进页面都会自动加载一次。我设置的一页10条记录,结果每次都是一开始加载就有20条记录,然后滑动到最下面时再添加10条。代码如下:
html:
<ion-content class="main">
<ion-refresher on-refresh="dragRefresh()"
pulling-text="下拉刷新"
refreshing-text="正在刷新"
refreshing-icon="ion-loading-b">
</ion-refresher>
<ul class="list_box">
<li ng-repeat="item in anacustlist">
<h4 class="fixed canEnter" ng-click="gotoDetail({{item.SERIALNO}})">
{{item.CUSTOMERNAME}}
<span class="list_arrow"></span>
</h4>
<div class="list_detail">
<p>预警状态<span class="list_state">{{item.ALARMSTATUS}}</span></p>
<p>管户人<span>{{item.INPUTUSERID}}</span></p>
<p class="list_date"><span>{{item.INPUTDATE}}</p></span>
</div>
</li>
</ul>
<ion-infinite-scroll
icon="ion-loading-c"
ng-if="!moreData()"
on-infinite="doRefresh()"
distance="10%">
</ion-infinite-scroll>
</ion-content>
controller.js:
.controller('CustomerListController', function($scope, $state,$ionicPopup,$http,$stateParams, $ionicLoading, $timeout,basePage) {
var iCurPage = 1;
var noData = false;
var iPageSize = 10;
var loadData = function(){
if($scope.anacustname) $scope.anacustname = "";
runService($http,$ionicLoading,"/json.jsp?method=custrisklist",{CustName:$scope.anacustname, CurPage:0, PageSize:iPageSize},
function(data,status){
$scope.anacustlist=data["datas"];
}
);
};
$scope.moreData = function(){
return noData;
}
$scope.dragRefresh = function() {
runService($http,$ionicLoading,"/json.jsp?method=custrisklist",{CustName:$scope.anacustname, CurPage:iCurPage, PageSize:iPageSize},
function(data,status){
$scope.anacustlist=data["datas"];
}
);
$scope.$broadcast('scroll.refreshComplete');
};
$scope.doRefresh = function() {
runService($http,$ionicLoading,"/json.jsp?method=custrisklist",{CustName:$scope.anacustname, CurPage:iCurPage, PageSize:iPageSize},
function(data,status){
if(data["datas"].length==0){
noData = true;
return;
}
if($scope.anacustlist){
$scope.anacustlist=$scope.anacustlist.concat(data["datas"]);
//alert($scope.anacustlist.length);
}
$timeout(function () {
$scope.$broadcast('scroll.refreshComplete');
$scope.$broadcast('scroll.infiniteScrollComplete');
}, 1000);
}
);
iCurPage++;
};
$scope.footActiveIndex = 4;
basePage.init($scope,loadData);
})
|
|