我正在使用 ngx-bootstrap 分页,并且尝试设置值来分页浏览 ts 文件。我从两个组件设置此值,在一个组件中设置值并将分页设置为页面,但在其他组件中它没有将值设置为当前页面
HTML:
<pagination
[boundaryLinks]="true"
(pageChanged)="pageChanged($event)"
[totalItems]="totalItems"
[(ngModel)]="currentPage"
previousText="‹" nextText="›" firstText="«" lastText="»"
[maxSize]="3">
</pagination>
我正在 ngOnInit() 中设置值:
this.currentPage = this.pageNavigaiton.first;
我尝试直接为当前页面赋予值:
this.currentPage = 3;
但这也不起作用
版本:
"ngx-bootstrap": "^2.0.0-rc.0",
最佳答案
在页面初始化中,您可以使用:setTimeout(() => this.currentPage =whateverNumberYouLike);
关于pagination - 如何在 ngx-bootstrap 分页中将值设置为(通过 TS 的当前页面)分页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51167799/