I want to declare pipe in parent module and use it in child modules.
@NgModule({
// Pipe which I want to declare in all child modules
declarations: [ ThisIsPipe ],
imports: [ ChildModuleOne, ChildModuleTwo],
})
How can I use It child modules?
Because if I declare it twice I got error
Uncaught Error: Type ThisIsPipe is part of the declarations of 2 modules: ChildModuleOne and ChildModuleTwo! Please consider moving ThisIsPipe to a higher module that imports ChildModuleOne and ChildModuleTwo. You can also create a new NgModule that exports and includes ThisIsPipe then imports that NgModule in ChildModuleOne and ChildModuleTwo.
You need to create another module where you put the pipe and then import that module where you want to use that pipe.
One directive, component, or pipe can always belong only to exact one NgModule but this NgModule can be imported to as many modules as desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With