【发布时间】:2023-04-06 11:09:01
【问题描述】:
我在 Angular4 项目中有一个“卡片”列表,我想每页只显示 6 个,我可以在桌子上使用分页,但是对于“卡片”我不能(我认为它正在等待行ans列,卡片的代码是:
<div style="position:relative;">
<table class="row">
<div id="jasmine_content" class="x_content col-lg-4 col-md-5 col-sm-8 col-form-label-sm" [ngbCollapse]="isCollapsed" *ngFor="let instance of entityList.list; trackBy:trackByFn; let idx=index;">
<div class="card mb-2 ">
<div class=" card-header table table-hover table-striped">
<td>
<ng-container *ngFor="let column of entityList.metadata.columns" [ngSwitch]="column.order" >
<tr *ngSwitchCase="2" >{{ entityName.toLowerCase() + '.' + column.key | translate}} -
{{getValue(instance, column.key) | ellipsis:200}}</tr>
<tr *ngSwitchCase="3" >{{ entityName.toLowerCase() + '.' + column.key | translate}} -
{{getValue(instance, column.key) | ellipsis:200}}</tr>
<tr *ngSwitchCase="5" >{{ entityName.toLowerCase() + '.' + column.key | translate}} -
{{getValue(instance, column.key) | ellipsis:200}}</tr>
</ng-container>
</td>
</div>
</div>
</div>
</table>
</div>
我拿到了卡片,但只有一页,我怎样才能以最简单的方式使用分页?
PS:在列表中,我使用下一行进行分页:
...
<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="table table-hover table-striped">
<thead>
<tr>
<th *ngFor="let column of entityList.metadata.columns">
{{ entityName.toLowerCase() + '.' + column.key | translate}}
</th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let instance of entityList.list; trackBy:trackByFn; let idx=index;">
<ng-container *ngFor="let column of entityList.metadata.columns" [ngSwitch]="column.type">
<td *ngSwitchCase="'date'">{{getValue(instance, column.key) | date:'y/MM/dd'}}</td>
<td *ngSwitchCase="'text'">{{getValue(instance, column.key) | ellipsis:200}}</td>
<td *ngSwitchCase="'boolean'">
<input type="checkbox" [checked]="getValue(instance, column.key)" disabled/></td>
<td *ngSwitchDefault>{{ getValue(instance, column.key)}}</td>
</ng-container>
</tr>
</tbody>
</table>
...
我在桌子上用线条和列进行分页。
【问题讨论】:
标签: angular pagination bootstrap-4