解决ionic和angular上拉加载的问题
说到ionic上拉加载就跟pc的分页是一样的,他需要在html数据列表的最下面边添加
<ion-infinite-scroll ng-if="hasmore" on-infinite="loadMore()" distance="10%"> </ion-infinite-scroll>
当列表为空 当ng-if为true的时候, 列表没有被填充满的时候 ,他就会自动加载loadMore();
<span style="font-size:18px;"> $scope.loadMore = function() { Msdk.postJSON('/informNotice/queryNoticeInfo', { pageIndex: $scope.newsList.pageIndex, pageSize: $scope.newsList.pageSize, informIds: $scope.newsList.informIds }, function(e) { if(e.length != 0) { //把每次请求到的数据都拼接起来 var a = $scope.notice; $scope.notice = a.concat(e); console.log($scope.notice); //广播上个加载结束,有条件进行下个加载 $scope.$broadcast('scroll.infiniteScrollComplete'); $scope.newsList.pageIndex++;</span>
<span style="font-size:18px;"> //如果请求到的数据小于pageSize,证明没数据可读</span> <span style="font-size:18px;"><span style="white-space:pre"> </span>//hasmore变为false,不会执行上拉加载 if(e.length < $scope.newsList.pageSize) { $scope.hasmore = false; } else {</span> [javascript] view plain copy <span style="font-size:18px;"><span style="white-space:pre"> </span>//为true有条件进行下次上拉加载 $scope.hasmore = true; } } else { $scope.hasmore = false; $scope.$broadcast('scroll.infiniteScrollComplete'); } }) }</span>
总结
相关推荐
绿豆饼 2020-07-28
半纸药笺 2020-07-26
半纸药笺 2020-06-14
芯果科技蔡彦 2020-04-30
芯果科技蔡彦 2020-04-14
kfq00 2020-04-10
samllcat 2020-03-27
ZillahV0 2016-08-27
半纸药笺 2019-11-18
qixiang0 2015-04-24
shichong 2015-05-14
庆华 2015-12-26
genglang 2016-05-01
琪凡睿 2016-04-28
GoDotDotDot 2018-12-12
WarmPure 2018-10-02
青 2017-09-19
GoDotDotDot 2017-07-21