I am trying to include ngb-pagination, how to make that work. this may be a duplicate but since that answer is not working I am posting it again.
I have no clue how to make it work
<tr *ngFor="let data of reportsData;let i = index; trackBy: trackByFn">
<td>{{data.time_stamp}}</td>
</tr>
</tbody>
<ngb-pagination [collectionSize]="50" [page]="1" [maxSize]="5" [rotate]="true" [boundaryLinks]="true"></ngb-pagination>
take a look at this working demo on plunker: Here
you can check the official docs over here: https://ng-bootstrap.github.io/#/components/pagination
<ngb-pagination [collectionSize]="70" [(page)]="page" [directionLinks]="false"></ngb-pagination>
in the component
import {Component} from '@angular/core';
@Component({
selector: 'ngbd-pagination-basic',
templateUrl: 'src/pagination-basic.html'
})
export class NgbdPaginationBasic {
//setting the default page
page :number = 1;
}
another alternative is to use the ngx-pagination as a simpler soultion take a look at the github repo: Here
I haven't do it yet but I think I found an answer for question every beginner ask (I am too):
Why ngb-pagination doesn't work?
You should slice your JSON data by pages and in component HTML iterate through sliced data (NOTICE: this is only view code example!).
<div *ngFor="let item of pagedItems">{{item.name}}</div>
More info you can find on this article and in this question.