[英]How to assign value to angular pagination custom template?
I am using custom template for angular pagination:我正在使用自定义模板进行角度分页:
<uib-pagination
boundary-links="(vm.pagination.boundaryLinks == false) ? false : true"
num-pages="vm.pagination.numPages"
total-items="vm.pagination.totalItems"
items-per-page="vm.pagination.itemsPerPage"
ng-model="vm.pagination.currentPage"
max-size="(vm.pagination.pager == true) ? 0 : 10"
template-url="pagination.html"
ng-change="vm.pagination.pageChanged(vm.pagination)">
</uib-pagination>
<script id="pagination.html" type="text/ng-template">
<ul class="pagination">
<li ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(1)" title="First Page"> {{'FIRST' | translate}}</a></li>
<li ng-class="{disabled: noPrevious()}"><a href ng-click="selectPage(page - 1)" title="Previous Page">{{'PREVIOUS' | translate}}</a></li>
<li ng-repeat="page in pages track by $index" ng-class="{active: page.active}"><a href ng-click="selectPage(page.number)">{{page.text}}</a></li>
<li ng-class="{disabled: noNext()}"><a href ng-click="selectPage(page + 1)" title="Next Page">{{'NEXT' | translate}}</a></li>
<li ng-class="{disabled: noNext()}"><a href ng-click="selectPage(vm.pagination.numPages)" title="Last Page">{{'LAST' | translate}}</a></li>
</ul>
</script>
<pre>Total: {{vm.pagination.numPages}}</pre>
It display nicely:它显示得很好:
The problem is with the Last
button.问题出在
Last
按钮上。 When I click it, it will not skip to last page.当我点击它时,它不会跳到最后一页。 However if I assign value directly like this
ng-click="selectPage(11)
and click Last
button, it will jump to the last page 11.但是,如果我像这样直接赋值
ng-click="selectPage(11)
并单击Last
按钮,它将跳转到最后一页 11。
With the last code above, vm.pagination.numPages
does contain value 11
.使用上面的最后一个代码,
vm.pagination.numPages
确实包含值11
。
Anyone can help me with this?任何人都可以帮助我吗? Thanks in advance.
提前致谢。
Your pagination template has isolated scope and, therefore, knows nothing about vm
.您的分页模板具有独立的范围,因此对
vm
一无所知。 Try selectPage(totalPages)
instead尝试
selectPage(totalPages)
代替
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.