标签:logs als gif color image baidu query else enter
效果演示
核心code
html
<ion-view view-title="学生list"> <ion-content > <ion-refresher spinner="spiral" on-refresh="doRefresh()"></ion-refresher> <div class="demoWrapp"> <div class="sutdentItem slide-top" ng-repeat="studnet in students"> <div>姓名:{{studnet.name}}</div> <div>年龄:{{studnet.age}}</div> </div> </div> <ion-infinite-scroll ng-if="hasMore" immediate-check="false" icon="ion-loading-c" on-infinite="loadMore()" distance="10%"> </ion-content> </ion-view>
js
testModule.controller(‘testCtrl‘,function($scope){ //模拟接口数据 var getSudent=function (data) { var page=data.page; if(page==1){ return { hasMore:true, list:[ {name:‘小明‘,age:10}, {name:‘小红‘,age:8}, {name:‘小黄‘,age:20}, {name:‘小黑‘,age:16}, {name:‘小白‘,age:14} ] } }else if (page==2){ return { hasMore:true, list:[ {name:‘小蓝‘,age:20}, {name:‘小青‘,age:10}, {name:‘小紫‘,age:10}, {name:‘小一‘,age:18}, {name:‘小二‘,age:12} ] } }else if (page==3){ return { hasMore:false, list:[ {name:‘张三‘,age:20}, {name:‘李四‘,age:10} ] } }else{ return { status:‘没有数据了‘ } } }; //获取学生list var queryStudent=function (param) { var result=getSudent(param); $scope.hasMore=result.hasMore;//判断还有没有更多 if(param.page==1){//判断是刷新还是加载更多 $scope.students=result.list; }else{ $scope.students= $scope.students.concat(result.list); } console.log($scope.students) $scope.$broadcast(‘scroll.refreshComplete‘); $scope.$broadcast(‘scroll.infiniteScrollComplete‘); }; //初始化进来的时候 var init=function() { $scope.hasMore=false; $scope.param={page:1 } queryStudent($scope.param) } $scope.$on("$ionicView.beforeEnter",init()) //下拉刷新 $scope.doRefresh=function () { init() } //上拉加载 $scope.loadMore=function () { $scope.param.page++; queryStudent($scope.param); } })
源码下载
http://pan.baidu.com/s/1mhTp2ys
标签:logs als gif color image baidu query else enter
原文地址:http://www.cnblogs.com/flyings/p/7641150.html