2

I am using ngx-bootstrap pagination and I am trying to set value to page through ts file. I am setting this value from two component and in one component value is setting and pagination is set to the page, but in other component it is not setting the value to current page

HTML:

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

I am setting value in ngOnInit():

 this.currentPage = this.pageNavigaiton.first;

I have tried giving directly value to the currentPage:

  this.currentPage = 3;

but this is also not working

version:

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

1 Answers1

2

In your page init you can use: setTimeout(() => this.currentPage = whateverNumberYouLike);

reckface
  • 5,678
  • 4
  • 36
  • 62