angular - 如何解决我的分页错误指示“它在类型上不存在”?
问题描述
我想为产品组件添加分页,因此最多只有 4 行 4 列,您必须按下一步按钮才能查看下一个产品。我尝试实现的分页给出了“类型不存在”错误。
html文件中的代码是:
<div class="row">
<div class="col-3" *ngFor="let product of products | paginate: {productsPerPage: 5, currentPage:p}" >
<a href="#" class="list-group-item clearfix" >
<span class="pull-left">
<img
src="{{ product.imagePath }}"
alt="{{ product.name }}" >
</span>
<div class="productName">
<p>{{product.name}} </p>
</div>
</a>s
<div id="pagination">
<pagination-controls (pageChange)="p=$event"></pagination-controls>
</div>
</div>
</div>
解决方案
<pagination-controls (pageChange)="p=$event"></pagination-controls>
而不是使用这个为什么你不尝试在组件中
<pagination-controls (pageChange)="pageChanged($event)"></pagination-controls>
并像这样调用你的下一个 api 请求
pageChanged(event: any): void {
this.apiService.getData(url?page=event);
}
推荐阅读
- javascript - 在组件重新加载时未调用 React componentDidMount
- php - 需要 MVC 的分页脚本
- automationanywhere - 使用 Automation Anywhere 的 RTC Jazz 服务器用户登录
- python - 每次我运行应用程序时都会出现“RuntimeError:生成器引发 StopIteration”。(没有任何作用)
- python - 如何建立 LSTM 网络来预测多序列?
- docker - 如何使用 ssh 连接获取卷数据
- spring-boot - 如何将 Spring-boot 调度器设计为 Service,以便其他微服务可以使用它
- python - Smtplib 代码在 python3.7 中适用于 linux 但不适用于 windows 10
- sql - ORA-01843: 在 maximo 上作为报告运行时不是有效的月份异常
- javascript - 如何减少drupal网站的TTFB时间