当前位置: 移动技术网 > IT编程>脚本编程>AngularJs > Angularjs分页查询的实现

Angularjs分页查询的实现

2018年05月01日  | 移动技术网IT编程  | 我要评论

 angularjs实现分页查询功能的实例代码,具体代码如下所示:

//首页导入<script type="text/javascript" src="framework/tm.pagination.js"></script> 
//routerapp中注入'tm.pagination' 
//html页面上<tm-pagination conf="paginationconf"></tm-pagination> 
//controller.js代码 
var research = function() { 
  var postdata = { 
    //发送给后台的请求数据 
    currentpage: $scope.paginationconf.currentpage, 
    pagesize: $scope.paginationconf.itemsperpage, 
    pickup: $scope.pickups, 
    starttime: $scope.starttime, 
    endtime: $scope.endtime, 
    minmoney: $scope.minmoney, 
    maxmoney: $scope.maxmoney 
  }; 
  $http.post('后台分页接口', postdata).success(function(response) { 
    $scope.paginationconf.totalitems = response.totalelements; //总条数 
    $scope.takegoodslists = response.content; //具体内容 
    //共享的数据赋值 
  }); 
} 
$scope.research = research; 
//配置分页基本参数 
$scope.paginationconf = { 
  currentpage: 1, //起始页 
  //totalitems:300,//总共有多少条记录 
  itemsperpage: 5, // 每页展示的数据条数 
  //pageslength:5,//分页条目的长度 
  perpageoptions: [5, 10, 20] //可选择显示条数的数组 
}; 
//当页码和页面记录数发生变化时监控后台查询如果把currentpage和itemsperpage分开监控的话则会触发两次后台事件。 
$scope.$watch('paginationconf.currentpage + paginationconf.itemsperpage', research); 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网