gpt4 book ai didi

angular - 无法绑定(bind)到 'totalItems',因为它不是 'pagination' 的已知属性

转载 作者:行者123 更新时间:2023-12-02 15:04:59 28 4
gpt4 key购买 nike

这是我的 HTML 分页标签

<pagination class="pagination-sm" [(ngModel)]="page" [totalItems]="length" [itemsPerPage]="itemsPerPage" [maxSize]="maxSize" [boundaryLinks]="true" [rotate]="false" (pageChanged)="changePage($event)" (numPages)="numPages = $event"></pagination>

和我的模型文件

import { Injectable } from '@angular/core';
import { NgbPaginationConfig} from '@ng-bootstrap/ng-bootstrap';

@Injectable()
export class PaginationConfig {
constructor(private config: NgbPaginationConfig) {
config.boundaryLinks = true;
config.maxSize = 5;
config.pageSize = 20;
config.size = 'sm';
}
}

我正在使用@ng-bootstrap/ng-bootstrap 的 GitHub 包,当时出现以下错误

Unhandled Promise rejection: Template parse errors:
Can't bind to 'itemsPerPage' since it isn't a known property of 'pagination'. ("
</tbody>
</table>
<pagination class="pagination-sm" [(ngModel)]="page" [ERROR ->][itemsPerPage]="itemsPerPage" [maxSize]="maxSize" [boundaryLinks]="true" [rotate]="false" (pageChange"): ng:///TeamModule/TeamComponent.html@83:54
Can't bind to 'maxSize' since it isn't a known property of 'pagination'. ("tbody>
</table>
<pagination class="pagination-sm" [(ngModel)]="page" [itemsPerPage]="itemsPerPage" [ERROR ->][maxSize]="maxSize" [boundaryLinks]="true" [rotate]="false" (pageChanged)="changePage($event)" (numPa"): ng:///TeamModule/TeamComponent.html@83:84
Can't bind to 'boundaryLinks' since it isn't a known property of 'pagination'. ("ination class="pagination-sm" [(ngModel)]="page" [itemsPerPage]="itemsPerPage" [maxSize]="maxSize" [ERROR ->][boundaryLinks]="true" [rotate]="false" (pageChanged)="changePage($event)" (numPages)="numPages = $ev"): ng:///TeamModule/TeamComponent.html@83:104
Can't bind to 'rotate' since it isn't a known property of 'pagination'. ("on-sm" [(ngModel)]="page" [itemsPerPage]="itemsPerPage" [maxSize]="maxSize" [boundaryLinks]="true" [ERROR ->][rotate]="false" (pageChanged)="changePage($event)" (numPages)="numPages = $event"></pagination>
</di"): ng:///TeamModule/TeamComponent.html@83:127
'pagination' is not a known element:
1. If 'pagination' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
</tbody>
</table>
[ERROR ->]<pagination class="pagination-sm" [(ngModel)]="page" [itemsPerPage]="itemsPerPage" [maxSize]="maxSiz"): ng:///TeamModule/TeamComponent.html@83:0 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
Can't bind to 'itemsPerPage' since it isn't a known property of 'pagination'. ("
</tbody>
</table>

仅在加载时出现上述错误

最佳答案

我想念模型文件 import ng-bootstrap

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

并在 @NgModel 内部为 root 导入

NgbModule.forRoot()

编辑:请注意 NgbModule 的 forRoot() 自 3.0.0 起已弃用,并将从 4.0.0 中删除。相反,建议只导入

NgbModule

关于angular - 无法绑定(bind)到 'totalItems',因为它不是 'pagination' 的已知属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47332509/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com