【问题标题】:how to set value to (current page thorugh TS)pagination in ngx-bootstrap pagination?如何在 ngx-bootstrap 分页中将值设置为(通过 TS 的当前页面)分页?
【发布时间】:2020-02-03 23:36:44
【问题描述】:

我正在使用 ngx-bootstrap 分页,我正在尝试将值设置为通过 ts 文件进行分页。我从两个组件中设置此值,在一个组件中设置值并将分页设置为页面,但在其他组件中它没有将值设置为当前页面

HTML:

    <pagination
  [boundaryLinks]="true"
  (pageChanged)="pageChanged($event)"
  [totalItems]="totalItems"
  [(ngModel)]="currentPage"
  previousText="&lsaquo;" nextText="&rsaquo;" firstText="&laquo;" lastText="&raquo;"
  [maxSize]="3">
</pagination>

我在 ngOnInit() 中设置值:

 this.currentPage = this.pageNavigaiton.first;

我尝试过直接给 currentPage 赋值:

  this.currentPage = 3;

但这也行不通

版本:

 "ngx-bootstrap": "^2.0.0-rc.0",

【问题讨论】:

  • 我得到了答案,我刚刚将条件放在 html 中,因为它是在分配值之前加载的
  • 您能在此处添加您的条件作为答案吗?我也面临同样的问题
  • @Shwet 只需使用 *ngIf 加载数据后为真

标签: pagination angular5 ngx-bootstrap


【解决方案1】:

在您的页面初始化中,您可以使用:setTimeout(() =&gt; this.currentPage = whateverNumberYouLike);

【讨论】:

    猜你喜欢
    • 2012-05-19
    • 2015-03-10
    • 2018-11-06
    • 2018-01-21
    • 2018-05-01
    • 2011-08-14
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    相关资源
    最近更新 更多