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: \
You need to register the pipes you want to use in a component:
@Component({
...
pipes: [filter],
template: `
{{item}}
`
...})
class SomeComponent {
someData = [ ... ];
}
@NgModule({
imports: [CommonModule],
declarations: [filter]
})
export class MyFilterModule()
To make the pipe available add the module to imports where you want to use it
@NgModule({
declarations: [AppComponent, SomeComponent],
imports: [BrowserModule, MyFilterModule]
})
export class AppModuleModule()
If you want to call the pipe from code
let f = new filter();
f.transform(value, filterArg);