首页 > 解决方案 > 如何解决我的分页错误指示“它在类型上不存在”?

问题描述

我想为产品组件添加分页,因此最多只有 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>

标签: angularbootstrap-4

解决方案


<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);
}

推荐阅读