简体   繁体   English

同一页上的两个角度ui引导分页不起作用

[英]Two angular ui bootstrap pagination on same page not working

I have 2 angular UI bootstrap pagination on the same page but my second pagination is not working properly. 我在同一页面上有2个角度UI引导分页,但是第二个分页无法正常工作。

My first pagination initialization is: 我的第一个分页初始化是:

<ul uib-pagination total-items="list_details.length" max-size="4" items-per-page="page_size" ng-model="current_page" ng-change="pageChanged()"> </ul>

Here i have set value for page_size as ng-init="page_size=50" on one of the parent DIV . 在这里,我在父DIV之一上将ng-init="page_size=50"值设置为ng-init="page_size=50"

My table tr is : 我的表tr是:

<tr ng-repeat="cl in list_details | limitTo: page_size:(current_page-1)*page_size"></tr>

My second pagination initialization is: 我的第二个分页初始化是:

<ul uib-pagination total-items="main_details.length" max-size="4" items-per-page="page_size_main" ng-model="current_page_main" ng-change="pageChanged()"></ul>

Here i have set value for page_size_main as ng-init="page_size_main=50" on one of the parent DIV . 在这里,我为父DIV之一设置了page_size_main的值为ng-init="page_size_main=50"

My table tr is : 我的表tr是:

<tr ng-repeat="em in main_details | limitTo: page_size_main:(current_page_main-1)*page_size_main"></tr>

Now the strange thing my first table has 14 record and first pagination is working properly. 现在奇怪的是我的第一个表有14条记录,并且第一个分页工作正常。 But for the second table, pagination is creating properly as per data length but the table is showing all records. 但是对于第二个表,可以根据数据长度正确创建分页,但是该表显示了所有记录。 So for the second, there is 58 record so as per page size 50, 2 page is creating but the table is showing all 58 records and pagination link is not working for the second table. 因此对于第二个表,有58条记录,因此每页大小为50,正在创建2页,但是该表显示所有58条记录,并且分页链接不适用于第二个表。

One more thing if I set first table's page size to 10 then second table's data is filtered to 10 but still pagination is not working for the second table. 还有一件事情,如果我将第一个表的页面大小设置为10,那么第二个表的数据将被过滤为10,但是分页对于第二个表仍然不起作用。 It's strange and I'm not getting the solution from anywhere. 很奇怪,我没有从任何地方得到解决方案。

Can someone help me, please? 有人能帮助我吗?

Downvoters give the reason so that I can improve my question. 拒绝投票的人给出原因,以便我可以改善我的问题。

I got the solution to my problem. 我已经解决了我的问题。 This may help someone so I am posting my own answer. 这可能会对某人有所帮助,所以我要发布自己的答案。 I have wrapped my second table pagination with parent div containing ng-if wrapper. 我用包含ng-if包装器的父div包装了第二个表分页。

<div ng-if="...some condition...">
      <ul uib-pagination total-items="main_details.length" max-size="4" items-per-page="page_size_main" ng-model="current_page_main" ng-change="pageChanged()"></ul></pagination>
</div>

This causes my ng-change not to fire twice as by the time the pagination is loaded my model item page has a value, hope this helps someone else. 这会导致我的ng-change不会触发两次,因为在分页加载时我的模型项目页面具有值,希望这对其他人有帮助。

So simply replace ng-if with ng-show and everything should be working fine. 因此,只需将ng-if替换为ng-show ,一切就可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM