Я пытаюсь добавить нумерацию страниц в свое приложение Angular, как описано в этой ссылке:
Перейти к «Переключение контента»
Я сделал это:
В app.module.ts :
import { PaginationModule } from 'ngx-bootstrap/pagination';
@NgModule({
imports: [
@NgModule({
]
})
В app.component.html :
<div class="container">
<div class="row">
<div class="row">
<div class="col-xs-12 col-12">
<div class="content-wrapper">
<p class="content-item" *ngFor="let content of returnedArray">{{content}}</p>
</div>
<pagination [totalItems]="contentArray.length" (pageChanged)="pageChanged($event)"></pagination>
</div>
</div>
</div>
</div>
В app.component.ts :
import { Component, OnInit, Injectable } from '@angular/core';
import { PageChangedEvent } from 'ngx-bootstrap/pagination';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
@Injectable({
providedIn: 'root'
})
export class AppComponent implements OnInit {
contentArray = new Array(90).fill('');
returnedArray: string[];
ngOnInit(): void {
this.contentArray = this.contentArray.map((v: string, i: number)
=> `Content line ${i + 1}`);
this.returnedArray = this.contentArray.slice(0, 10);
}
pageChanged(event: PageChangedEvent): void {
const startItem = (event.page - 1) * event.itemsPerPage;
const endItem = event.page * event.itemsPerPage;
this.returnedArray = this.contentArray.slice(startItem, endItem);
}
}
Но при компиляции у меня появляется следующая ошибка:
core.js: 15724 Ошибка ОШИБКИ: Uncaught (в обещании): ошибка: StaticInjectorError (RootModule) [PaginationComponent -> PaginationConfig]: StaticInjectorError (платформа: ядро) [PaginationComponent -> PaginationConfig]: NullInjectorError: Нет поставщика для PaginationConfig!Ошибка: StaticInjectorError (RootModule) [PaginationComponent -> PaginationConfig]: StaticInjectorError (Платформа: ядро) [PaginationComponent -> PaginationConfig]: NullInjectorError: Нет поставщика для PaginationConfig!в NullInjector.push ../ node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js: 8896) в resolToken (core.js: 9141) в tryResolveToken (core.js: 9085)
Есть идеи, что случилось?