【发布时间】:2018-04-10 10:31:30
【问题描述】:
我正在使用 ngx-pagination 库,当我使用它一次时,它非常适合我的可重用数据表组件,但是多次使用该组件会导致分页仅在一个组件上工作。如果可能的话,我怎样才能使这个分页可重用?
table.component.html
<table>
<thead>
<tr>
<th *ngFor="let col of cols">
<label>{{col.header}}</label>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of data | paginate: { itemsPerPage: 6,
currentPage: p }">`
<td *ngFor="let col of cols">
{{row[col.prop]}}
</td>
</tr>
</tbody>
</table>
<pagination-controls
class="my-pagination"
(pageChange)="p = $event">
</pagination-controls>
table.component.ts
@Component({
selector: 'app-data-table',
templateUrl: './data-table.component.html',
styleUrls: ['./data-table.component.css']
})
export class DataTableComponent {
@Input() data
@Input() cols
p: number = 1
}
【问题讨论】:
标签: angular pagination