图表的简单分页,功能不全但是采用异步请求的方法,留以后查询吧
景区画像
序号 景区名称 客流统计(入) 车流统计(出) 门票销售(张) 门票收入(元) 接团数量
app.constant("host", "http://172.16.40.XX");app.controller('spotphotoCtrl',['$scope','$http','host' ,function($scope,$http,host) { $scope.urlfor=function( pagenow, pageSize){ $scope.urla = host + "/API/BigData/GetScenicInfo?pageCurrent="+pagenow+"&pageSize="+pageSize; $http.get($scope.urla).success(function (response) { var models = eval(response); $scope.items =models.Data; }); } }]); /***************************************分页指令*******************************************************/app.directive('pagination', function() { return { restrict: 'E', template: ' ', replace: true, link: function($scope, element, attrs, controller) { $scope.pages =100 //分页数 $scope.pageSize = 7; $scope.pageList = [];//显示页数 $scope.selPage = 1; //设置表格数据源(分页) $scope.setData = function (page) { $scope.urlfor(page,$scope.pageSize) } $scope.urlfor($scope.selPage,$scope.pageSize) //分页要repeat的数组 for (var i = 0; i < $scope.newPages; i++) { $scope.pageList.push(i + 1); } $scope.selectPage = function (page) { //不能小于1大于最大 if (page < 1 || page > $scope.pages) return; //最多显示分页数5 if (page > 2) { //因为只显示5个页数,大于2页开始分页转换 var newpageList = []; for (var i = (page - 3); i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)); i++) { newpageList.push(i + 1); } $scope.pageList = newpageList; } $scope.selPage = page; $scope.setData(page); $scope.isActivePage(page); console.log("选择的页:" + page); }; //设置当前选中页样式 $scope.isActivePage = function (page) { return $scope.selPage == page; }; //上一页 $scope.Previous = function () { $scope.selectPage($scope.selPage - 1); } //下一页 $scope.Next = function () { $scope.selectPage($scope.selPage + 1); }; } };});