Problem with the same pipe component declarations in child modules

I want to declare a channel in a 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 an error

Uncaught Error: Type ThisIsPipe is part of the declarations of two 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 this NgModule into ChildModuleOne and ChildModuleTwo.

+5
source share
2 answers

You need to create another module in which you place the handset, and then import this module where you want to use this channel.

One directive, component or tube can always belong to only one NgModule, but this NgModule can be imported into any number of modules as desired.

+5
source
-1
source

Source: https://habr.com/ru/post/1257457/


All Articles