I want to create a dynamic pipe which I am going to call from the component.
import {Component, Pipe, PipeTransform} from \'angular2/core\';
@Pipe({ name: \
In case you want to use your pipe on different modules several times, I suggest you aggregate all of your pipes into one module (e.g., PipesAggrModule) and then import this module into the wanted module. For instance:
my-pipe.module.ts
@Pipe({name: 'MyPipe'})
export class MyPipe { ... }
pipes-aggr.module.ts:
@NgModule({
imports: [
CommonModule
],
exports: [
...
MyPipe,
MyPipe2,
...
],
declarations: [..., MyPipe, MyPipe2, ...]
})
export class PipesAggrModule {}
Then, to use your pipes, simply import the import the PipesAggrModule into the wanted module.
my.module.ts
@NgModule({
imports: [
CommonModule,
PipesAggrModule
],
...
}
export class MyModule {}