I\'m just updating my angular2-app
to new RC5
. I got quite far, and everything seems ok, but now I want to re-organize it into NgModules
You have to make a module for the shared component and import this module where you want to use this component.
As the error messages says a component (or directive, or pipe) can only be listed in directives
of exactly one module.
If you want to reuse, then you need to add the module that contains it to @NgModule({imports: [...]})
of the module where you want to use it.
I make a module that contains ALL my shared components.
This makes it much easier to import it in my other modules.
Pro tip: put routing into your modules, and try - just for fun - to make one of them lazy loaded.
Then you'll think: "whoaaaaa modules are cooooolllll"
You have to use shared module.
SharedModule exists to make commonly used components, directives and pipes available for use in the templates of components in many other modules.
You have to export & import it in other modules where ever you want.
for more details see the link shared module