Angular 6-共享模块中的自定义管道未导出

Eas*_*all 5 typescript angular-pipe ng-modules angular

我的Angular架构由3个模块组成。

  • AppModule (应用预置和逻辑所在的位置)
  • CoreModule (包含我的服务以访问API)
  • SharedModule (包含我的模型,管道,指令等...)

我想在我添加一个新的管道SharedModule,所以我创建它,然后将其添加到declarationsexports该领域SharedModuleNgModule装饰。

然后,在中AppModule导入,SharedModule并且应该可以访问我的管道。但是,那件事,我做不到。相反,我有以下错误:

未捕获的错误:模板解析错误:找不到管道“ rankingposition”

有代码:

rankposition.pipe.ts

import { Pipe, PipeTransform } from "@angular/core";

@Pipe({ name: 'rankingposition' })
export class RankingPositionPipe implements PipeTransform {
    transform(value: any, ...args: any[]) {
        // Do stuff    
    }
}
Run Code Online (Sandbox Code Playgroud)

shared.module.ts

import { NgModule } from "@angular/core";
import { RankingPositionPipe } from "@app/shared/pipes/ranking-position.pipe";

@NgModule({
    declarations: [RankingPositionPipe],
    exports: [RankingPositionPipe]
})
export class SharedModule {}
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import { NgModule } from '@angular/core';
...
import { SharedModule } from '@app/shared/shared.module';

@NgModule({
  declarations: [...],
  imports: [
    ...,
    SharedModule
  ],
  providers: [],
  bootstrap: [...]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

编辑:添加我的组件代码:

rank.component.ts

import { Component } from "@angular/core";
import { CharacterModel } from "@app/shared/models/character.model";

@Component({
    selector: 'ranking',
    templateUrl: './ranking.component.html'
})
export class RankingComponent {
    public characters: Array<CharacterModel>;

    constructor() {
        this.characters = new Array<CharacterModel>();
    }
}
Run Code Online (Sandbox Code Playgroud)

rank.component.html

<div class="card">
  <div class="card-header">
    Ranking
  </div>
  <div class="card-body">
    <ul>
      <li *ngFor="let character of characters; let i = index">
        {{ character.level | rankingposition }}
      </li>
    </ul>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?