我是 Angular 的新手,所以我遇到了这个问题。
<div class="col-md-4" *ngFor="let student of students | paginate: {itemsPerPage:5, currentPage: p, totalItems: len}">
{{student.name}}
</div>
<pagination-controls (pageChange)="p =$event"></pagination-controls>
我收到此错误
无法在 PaginatePipe.push../node_modules/ngx-pagination/dist/ngx-pagination.js.PaginatePipe.transform 读取未定义的属性“totalItems”
组件代码:
public students= [];
public len;
ngOnInit() {
this.serverService.getStudents().subscribe(
data => {
this.students= data,
this.len = this.students.length
}
);
}