2

I have installed ngx pagination in angular 4. Everything works fine. I want to display records per page. ie. (Showing: 1 - 10 / 25 ). I have tried but i did not get any solution. Could you please help me on this. Thanks in advance.

The.Bear
  • 5,621
  • 2
  • 27
  • 33

2 Answers2

1

i have worked in this way and it helped,

 public setPageNumbers(pageNo,pageSize) {
    this.startValue = (pageNo * pageSize) - (pageSize -1)
    this.lastValue = this.agentParms.pageNo * this.agentParms.pageSize;
    this.lastValue = this.lastValue > this.agentTotal ? this.agentTotal: this.lastValue;
  }

so here i am multiplying, with current page number and page size, and subtracting with the current page size, so i get the first value, and to obtain last value, checking with page no. and page size, and displaying that as last value.. If the last value is greater than the total count, then the total count is taken as the last value.

Hope this helps.

Bhrungarajni
  • 2,415
  • 11
  • 44
  • 88
0

You can use PaginatePipe at the end of an NgFor expression.And you can pass number of records you want to display as config option.

<element *ngFor="let item of collection | paginate: { itemsPerPage: pageSize,
                                                  currentPage: p,}">...</element>
Ankita Gupta
  • 573
  • 3
  • 13
  • Thank you for your quick reply. I have already done this pagination. I want to display (Showing: 11 - 20 / 25) like this at the bottom. – bashirudeen ahmad Feb 13 '18 at 05:32