类似于this问题,但角度具体:
我只想在分页中一次最多显示5页。如果可能,当前页面应居中。简要说明:
< [1] 2 3 4 5 > // not centered
< 1 [2] 3 4 5 > // not centered
< 1 2 [3] 4 5 > // centered
< 2 3 [4] 5 6 > // remains centered
< 3 4 [5] 6 7 > // remains centered
我对如何处理此事感到茫然。
这就是我的观点:
<section>
<div class="center">
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="previous" ng-class="{ 'disabled': prevDisabled }">
<a href="#" ng-click="seek(page-1)" aria-label="Previous">
<i class="arrow_left"></i>
</a>
</li>
<li ng-repeat="(key,val) in pages" ng-class="{'active': key == page }"><a href="#" ng-click="seek(key)">{{key}}</a></li>
<li class="next" ng-class="{ 'disabled': nextDisabled }">
<a href="#" ng-click="seek(page+1)" aria-label="Next">
<i class="arrow_right"></i>
</a>
</li>
</ul>
</nav>
</div>
</section>