angular - 多个 ngx 分页错误 Angular 2

标签 angular angular2-template angular2-services angular2-directives

我在我的一个项目中使用 angular 2,我正在使用 ngx-pagination 对表格进行分页。我的页面结构是这样的

parent->child1=table1
        child2-table-2
        child-table-3
        child4-table-4

每个 child 都调用自己的休息请求并填充表格。我在父级中使用了子组件,如下所示

<div class="thirteen wide column" name="leave" id="leaveApproval">
    <div class="ui extended segment">
        <app-leave-approval></app-leave-approval>
        <div #leaveApproval></div>
    </div>
</div>
<div class="thirteen wide right floated column" #timesheetApproval name="timesheet" id="timesheetApproval">
    <div class="ui extended segment">
        <app-timesheetapproval></app-timesheetapproval>
    </div>
</div>

<div class="thirteen wide right floated column" #resourceApproval name="resource" id="resourceApproval">
    <div class="ui extended segment">
        <app-resource-approval></app-resource-approval>

    </div>
    <div></div>
</div>

等等

在每个子组件中我都使用了 ngx-pagination

<tr *ngFor="let data of exitProcessPendingList | paginate: { itemsPerPage: 7, currentPage: pgNumber};let i=index">

<pagination-controls (pageChange)="pgNumber = $event"></pagination-controls>

并且每个 child 都有唯一的 pageNumber 变量;

现在我面临的问题是,当我尝试更改一个表的页码时,它也会影响其他子表。如果我单击第一个表的第 2 页,所有其他表格将其当前页面更改为第 2 页。我做错了什么?我做的方式有什么问题吗?

最佳答案

通过在模板中指定 id 解决了我的问题

<pagination-controls  id="some_id" (pageChange)="pageChanged($event)" ></pagination-controls>

| paginate: { id: 'foo'},

关于angular - 多个 ngx 分页错误 Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45588455/

相关文章:

Angular Material : Mat Table sometimes get updated in real-time sometimes not

javascript - Angular 的 FormArray 什么时候是传统数组,什么时候是 FormArray 对象?

使用 IIS URL 重写重新加载时,Angular 应用程序未加载参数

angular - Angular Material 中的动态值 - 排序 header

Angular 2 : Convert XML to JSON

angular - 数据未从 Firebase 数据库中检索

Angular 2/Angular 4 : How can I access file from the local system location?

angular - 将 null 设置为输入字段的空字符串值

angular - 通过服务可观察到的失败在组件之间进行通信

angular2-services - Angular 2 对预检请求的响应未通过访问控制检查 : No 'Access-Control-Allow-Origin' header