Javascript 错误:StaticInjectorError(AppModule)[分页组件->分页配置]

Javascript 错误:StaticInjectorError(AppModule)[分页组件->分页配置],javascript,node.js,angular,typescript,ecmascript-6,Javascript,Node.js,Angular,Typescript,Ecmascript 6,我正在尝试向我的Angular应用程序添加分页,如此链接中所述: 我这样做: 在app.module.ts中: 在app.component.html中: 但当我编译时,我有以下错误: core.js:15724错误:未捕获承诺:错误:StaticInjectorErrorRootModule[PaginationComponent->PaginationConfig]: StaticInjectorErrorPlatform:core[PaginationComponent->Paginati

我正在尝试向我的Angular应用程序添加分页,如此链接中所述:

我这样做:

在app.module.ts中:

在app.component.html中:

但当我编译时,我有以下错误:

core.js:15724错误:未捕获承诺:错误:StaticInjectorErrorRootModule[PaginationComponent->PaginationConfig]: StaticInjectorErrorPlatform:core[PaginationComponent->PaginationConfig]: NullInjectorError:没有分页配置的提供程序! 错误:StaticInjectorErrorModule[分页组件->分页配置]: StaticInjectorErrorPlatform:core[PaginationComponent->PaginationConfig]: NullInjectorError:没有分页配置的提供程序! 在NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get core.js:8896 在resolveToken core.js:9141 在tryResolveToken core.js:9085


有什么问题吗?

应该是这样吗

从“ngx引导”导入{PaginationModule}; @NGD模块{ 导入:[分页模块.forRoot,…] }
就这样。。。一秒钟前刚找到解决方案。为什么有时需要添加forRoot?很抱歉问你这个问题。。。Angular中的新手…当您使用forRoot时,它将是应用程序范围内的
import { PaginationModule } from 'ngx-bootstrap/pagination';

@NgModule({
   imports: [
       @NgModule({
    ]
})
<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>
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);
   }
 }