【发布时间】:2020-08-06 01:11:42
【问题描述】:
我尝试在我的 Angular 10 应用程序中从 ngx-bootstrap 实现分页。目前记录数为 93 条,每页显示 93 条记录,共 10 页,一次显示 5 页。一次显示 5 页是正确的,因为 maxsize 设置为 5。不知道出了什么问题 itemsperpage 因为我已将其设置为 5,但它显示所有 93
<div *ngIf="customerDetails">
<table id="customerdetails-table" class="table table-bordered table-striped">
<thead>
<th>Customer</th>
<th>Company Name</th>
<th>Contact Name</th>
<th>Address</th>
<th>City</th>
<th>Postal Code</th>
<th>Country</th>
<th>Phone</th>
<th>View Order</th>
</thead>
<tbody>
<tr *ngFor="let custDetails of customerDetails">
<td>{{custDetails.customerId}}</td>
<td>{{custDetails.companyName}}</td>
<td>{{custDetails.contactName}}</td>
<td>{{custDetails.address}}</td>
<td>{{custDetails.city}}</td>
<td>{{custDetails.postalCode}}</td>
<td>{{custDetails.country}}</td>
<td>{{custDetails.phone}}</td>
<td>{{custDetails.customerId}}</td>
</tr>
</tbody>
</table>
<pagination [totalItems]="totalItems" [itemsPerPage] = "5" [maxSize]="maxSize" ></pagination>
</div>
组件
totalItems: number;
maxSize = 5;
ngOnInit(): void {
this.getCustomerDetails();
}
getCustomerDetails(): void {
this.customerDetailsService.getCustomerDetails()
.subscribe( data => { this.customerDetails = data;
this.totalItems = data.length;
}
);
}
【问题讨论】:
标签: angular ngx-bootstrap