我是angular的新手,所以我有这个问题。
{{student.name}}我得到了这个错误
无法在PaginatePipe.push../node读取未定义的属性“”totalItems“”_modules/ngx-pagination/dist/ngx-pagination.js.PaginatePipe.transform
组件代码:
public students= [];
public len;
ngOnInit() {
this.serverService.getStudents().subscribe(
data => {
this.students= data,
this.len = this.students.length
}
);
}发布于 2020-01-15 21:01:16
{{item['name']}}
{{item['code']}}发布于 2021-02-23 19:29:26
我不认为你需要使用totalItems作为这里的分页属性。ngx-pagination将自动将列表/数组的长度视为总项。
{{student.name}}这将解决您的原始问题/错误:
无法在PaginatePipe.push../node读取未定义的属性“”totalItems“”_modules/ngx-pagination/dist/ngx-pagination.js.PaginatePipe.transform
发布于 2020-01-15 21:08:18
I am working at Angular 8. This code is helpful to use the
pagination. I declare base url in API_URL in environment.ts.
example: API_URL:"http....",
endpoint: country
HTML code:
{{item['name']}}
{{item['code']}}example.component.ts:
con:any;
ngOnInit() {
this.http.get(`${environment.API_URL}/country`).subscribe(res=>{
this.con=res
})
}https://stackoverflow.com/questions/52759918
复制相似问题