sdfsadf
<div class="pageNum middle PT10"> <a href="javascript:void(0);" ng-show="pager.pageIndex>1" ng-click="pager.setFirstPage()">首页</a> <a href="javascript:void(0);" ng-show="pager.pageIndex>1" ng-click="pager.setPreviousPage()">上一页</a> <a href="javascript:void(0);" class="{{(page==pager.pageIndex)?'current':''}}" ng-repeat="page in pager.rangePages " ng-click="pager.setPage(page)">{{page}}</a> <a href="javascript:void(0);" ng-show="pager.pageIndex<pager.getMaxPages()" ng-click="pager.setNexPage()">下一页</a> <a href="javascript:void(0);" ng-show="pager.pageIndex<pager.getMaxPages()" ng-click="pager.setLastPage()">尾页</a> </div>
updateRangePages: function(){ var pageNums = [] var curPage = this.pageIndex var maxPage = this.getMaxPages() var begin = parseInt(curPage-5)>1?parseInt(curPage-5):1 var end = parseInt(begin+10)>maxPage?maxPage:parseInt(begin+10) if(parseInt(curPage-5)>1){ pageNums.push(1) pageNums.push('...') } while(begin<=end){ pageNums.push(begin++) } /* 页面出错 Error: [ngRepeat:dupes] http://errors.angularjs.org/1.2.20/ngRepeat/dupes?p0=page%20in%20pager.rangePages&p1=string%3A... */ try{ if(end<maxPage){ pageNums.push('...') pageNums.push(maxPage) } } catch(e){ console.log(e) } delete this.rangePages this.rangePages = pageNums }
出现错误,什么原因呢?
http://errors.angularjs.org/1.2.20/ngRepeat/dupes?p0=page%20in%20pager.rangePages&p1=string%3A...
经确定,因为有相同的内容而重复引起,所以前端需修改下黄色标记。
<div class="pageNum middle PT10"> <a href="javascript:void(0);" ng-show="pager.pageIndex>1" ng-click="pager.setFirstPage()">首页</a> <a href="javascript:void(0);" ng-show="pager.pageIndex>1" ng-click="pager.setPreviousPage()">上一页</a> <a href="javascript:void(0);" class="{{(page==pager.pageIndex)?'current':''}}" ng-repeat="page in pager.rangePages track by $index" ng-click="pager.setPage(page)">{{page}}</a> <a href="javascript:void(0);" ng-show="pager.pageIndex<pager.getMaxPages()" ng-click="pager.setNexPage()">下一页</a> <a href="javascript:void(0);" ng-show="pager.pageIndex<pager.getMaxPages()" ng-click="pager.setLastPage()">尾页</a> </div>
参考