我正在使用 angular 11 并尝试实现分页
HTML
<tbody>
<tr *ngFor="let order of orders | paginate: config;let i = index">
<th scope="row" style="display:none;">{{ i + 1 }}</th>
<td>{{ order.Code }}</td>
<td>{{ order.quantity }}</td>
</tr>
</tbody>
</table>
<pagination-controls id="basicPaginate" (pageChange)="pageChanged($event)"></pagination-controls>
app.module.ts
......
import { NgxPaginationModule } from 'ngx-pagination';
imports: [
.......
RouterModule.forRoot(AppRoutes,{
useHash: true
}),
.......
NgxPaginationModule
]
订单组件
export class OrderComponent implements OnInit {
orders : Order [] = [];
config:any;
constructor(private orderService : OrderService {
this.config = {
id: 'basicPaginate',
itemsPerPage: 5,
currentPage: 1,
totalItems: 50
};
}
ngOnInit(){
//web service ok
this.orderService.getAllOrders(30,5,0).pipe(first()).subscribe(orders => this.orders = orders);
}
pageChanged(event) {
this.config.currentPage = event;
}
}
项目编译正常
那么为什么会发生这个错误呢?我只想要基本的分页而不是自定义的分页。Angular 11 是否存在兼容性问题?