Each pipe, component and directive must be declared in the module. This is because the compiler relies on module declarations for template analysis. If he did not see MyPipein the module declarations (or declarations of the imported module), then he will not look for it and not recognize when you use the channel in the template
If it is important that no other component can see your pipe, create a module that contains only the component that uses the pipe and the pipe itself, and do not export this pipe.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MyPipe } from './my.pipe';
import { MyComponent } from './my.component';
@NgModule({
imports: [ CommonModule ],
declarations: [ MyComponent, MyPipe ],
exports: [],
providers: []
})
export class MyModule { }
source
share