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.
Asked
Active
Viewed 2,854 times
2

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

bashirudeen ahmad
- 213
- 6
- 18
-
http://embed.plnkr.co/JVQMPvV8z2brCIzdG3N4/ – Suhel Feb 12 '18 at 11:25
-
@bashirudeen, have you got answer for your question? i am also struck with same kind of issue – Bhrungarajni Dec 30 '19 at 09:58
-
@Bhrungarajni I am also looking for this solution – C.Ikongo Jan 01 '20 at 04:27
-
@C.Ikongo, i have made as custom code and that worked for me, i will post my answer, you can have a look – Bhrungarajni Jan 01 '20 at 06:35
-
@Bhrungarajni I will give it a go when I have the chance – C.Ikongo Jan 16 '20 at 23:08
2 Answers
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