I am new to Angular 4 and I would appreciate if somebody could tell me how I can add pagination in a table.
Below is my code:
HTML:
<div *ngIf="tableDiv && adv1" id="adv1Div">
<table class="table table-hover" id="adv1Table">
<thead>
<tr class="black-muted-bg" >
<th class="align-right" *ngFor="let data of calendarTable[0].weeks">{{data.period}}</th>
</tr>
</thead>
<tbody>
<tr class="no-top-border" *ngFor="let item of calendarTable| paginate: { itemsPerPage: 9, currentPage: p };">
<td contenteditable='true' *ngFor="let data of item.weeks| paginate: { itemsPerPage: 9, currentPage: p };" class="align-right">{{data.price}}</td>
</tr>
</tbody>
<a href="javascript:void(0)">
{{p}}
</a>
</table>
</div>
And my JSON is :
public calendarTable = [
{ name: "TV AD1",
weeks: [
{ period: "2/10/2017", price: "400" },
{ period: "9/10/2017", price: "800" },
{ period: "16/10/2017", price: "200" },
{ period: "23/10/2017", price: "500" },
{ period: "30/10/2017", price: "600" },
{ period: "6/11/2017", price: "800" },
{ period: "13/11/2017", price: "700" },
{ period: "20/11/2017", price: "800" },
{ period: "27/11/2017", price: "900" },
{ period: "4/12/2017", price: "400" },
{ period: "11/12/2017", price: "800" },
{ period: "18/12/2017", price: "200" },
{ period: "25/12/2017", price: "500" },
{ period: "1/1/2018", price: "600" },
{ period: "8/1/2018", price: "800" },
{ period: "15/1/2018", price: "700" },
{ period: "22/1/2018", price: "800" },
{ period: "29/1/2018", price: "900" }
]
}
]
I want to add 5 items per page in a table. Please help me in this regard.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…