如何将Angular JS分页功能改写为支持长尾关键词的查询?

2026-04-06 11:362阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计438个文字,预计阅读时间需要2分钟。

如何将Angular JS分页功能改写为支持长尾关键词的查询?

plaintextgistfile1.txt: controller('store_device-ctrl', ['$scope', 'adService', '$rootScope', function($scope, adService, $rootScope) { console.log(全局 + $scope.myShopid); // 我的设备功能}])

gistfile1.txt

controller('store_device-ctrl', ['$scope', 'adService', '$rootScope', //我的设备 function ($scope, adService, $rootScope) { console.log("全局" + $scope.myShopid); //####################################### 账号查询所有设备 ######################################## $scope.count = 0; //默认总页数 $scope.p_pernum = 5; //页面大小 $scope.p_current = 1; //当前页 $scope.p_all_page = 0; //尾页 $scope.pages = []; //初始化页码 var _get = function (page, size) { var url = "device/queryDevice/" + $rootScope.myShopid + "/" + page + "/" + size + "?_=" + new Date().getTime(); ////wifiDre.json?status=0&page="+page+"&size="+size+""; var success = function (res) { console.log("分页查询设备"); console.log(res); $scope.id = res.id $scope.deviceTotal = res.deviceTotal; $scope.deviceInlineTotal = res.deviceInlineTotal; $scope.shopNum = res.shopNum; $scope.shopAdrr = res.addr; $scope.devices = res.deviceExtModels; $scope.count = res.deviceTotal; //总页码,后台传过来 $scope.p_current = page; //当前页码 $scope.p_all_page = Math.ceil($scope.count / $scope.p_pernum);//一共有多少页(总页数除以页面大小) reloadPno(); //初始化页码 }; console.log("当前" + url); adService.get(url, null, success, null); } //加载数据 _get($scope.p_current, $scope.p_pernum);//调用函数加载数据 //上一页 $scope.p_index = function () { if ($scope.p_current != 1) { $scope.load_page($scope.p_current - 1); } } //下一页 $scope.p_last = function () { if ($scope.p_current != $scope.p_all_page) { $scope.load_page($scope.p_current + 1); } } //加载某一页 $scope.load_page = function (page) { _get(page, $scope.p_pernum); }; //初始化页码 var reloadPno = function () { $scope.pages = calculateIndexes($scope.p_current, $scope.p_all_page, 4); //最后参数必须为偶数 console.log("分页算法" + $scope.pages); }; //分页算法 var calculateIndexes = function (current, length, displayLength) { var indexes = []; var start = Math.round(current - displayLength / 2); var end = Math.round(current + displayLength / 2); if (start <= 1) { start = 1; end = start + displayLength - 1; if (end >= length - 1) { end = length - 1; } } if (end >= length - 1) { end = length; start = end - displayLength + 1; if (start <= 1) { start = 1; } } for (var i = start; i <= end; i++) { indexes.push(i); } return indexes; }; //////////////////////////////////////// html //////////////////////////// 总记录数{{count}} 共:{{p_all_page}} 页

  • <
  • {{ page }}
  • >

如何将Angular JS分页功能改写为支持长尾关键词的查询?

本文共计438个文字,预计阅读时间需要2分钟。

如何将Angular JS分页功能改写为支持长尾关键词的查询?

plaintextgistfile1.txt: controller('store_device-ctrl', ['$scope', 'adService', '$rootScope', function($scope, adService, $rootScope) { console.log(全局 + $scope.myShopid); // 我的设备功能}])

gistfile1.txt

controller('store_device-ctrl', ['$scope', 'adService', '$rootScope', //我的设备 function ($scope, adService, $rootScope) { console.log("全局" + $scope.myShopid); //####################################### 账号查询所有设备 ######################################## $scope.count = 0; //默认总页数 $scope.p_pernum = 5; //页面大小 $scope.p_current = 1; //当前页 $scope.p_all_page = 0; //尾页 $scope.pages = []; //初始化页码 var _get = function (page, size) { var url = "device/queryDevice/" + $rootScope.myShopid + "/" + page + "/" + size + "?_=" + new Date().getTime(); ////wifiDre.json?status=0&page="+page+"&size="+size+""; var success = function (res) { console.log("分页查询设备"); console.log(res); $scope.id = res.id $scope.deviceTotal = res.deviceTotal; $scope.deviceInlineTotal = res.deviceInlineTotal; $scope.shopNum = res.shopNum; $scope.shopAdrr = res.addr; $scope.devices = res.deviceExtModels; $scope.count = res.deviceTotal; //总页码,后台传过来 $scope.p_current = page; //当前页码 $scope.p_all_page = Math.ceil($scope.count / $scope.p_pernum);//一共有多少页(总页数除以页面大小) reloadPno(); //初始化页码 }; console.log("当前" + url); adService.get(url, null, success, null); } //加载数据 _get($scope.p_current, $scope.p_pernum);//调用函数加载数据 //上一页 $scope.p_index = function () { if ($scope.p_current != 1) { $scope.load_page($scope.p_current - 1); } } //下一页 $scope.p_last = function () { if ($scope.p_current != $scope.p_all_page) { $scope.load_page($scope.p_current + 1); } } //加载某一页 $scope.load_page = function (page) { _get(page, $scope.p_pernum); }; //初始化页码 var reloadPno = function () { $scope.pages = calculateIndexes($scope.p_current, $scope.p_all_page, 4); //最后参数必须为偶数 console.log("分页算法" + $scope.pages); }; //分页算法 var calculateIndexes = function (current, length, displayLength) { var indexes = []; var start = Math.round(current - displayLength / 2); var end = Math.round(current + displayLength / 2); if (start <= 1) { start = 1; end = start + displayLength - 1; if (end >= length - 1) { end = length - 1; } } if (end >= length - 1) { end = length; start = end - displayLength + 1; if (start <= 1) { start = 1; } } for (var i = start; i <= end; i++) { indexes.push(i); } return indexes; }; //////////////////////////////////////// html //////////////////////////// 总记录数{{count}} 共:{{p_all_page}} 页

  • <
  • {{ page }}
  • >

如何将Angular JS分页功能改写为支持长尾关键词的查询?