Debashish dwivedi
Debashish dwivedi

Reputation: 65

how to set value to (current page thorugh TS)pagination in ngx-bootstrap pagination?

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",

Upvotes: 2

Views: 2294

Answers (1)

reckface
reckface

Reputation: 5858

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

Upvotes: 3

Related Questions