简体   繁体   中英

Type Y is part of the declarations of 2 modules - Angular 2

I want to include a shared component "SimpleRadialChartComponent" in two separate modules in my angular 2 application. When I pass this component in declarations area in each module, I took this error:

Type SimpleRadialChartComponent is part of the declarations of 2 modules

How can declare a shared component in two different modules?

Good pracitice is creating "shared" module for components, model objects, etc using in two or more modules.

All the guidelines and good practices you will find in official documentation .


Detailed description of your problem, you can find here :

If you want to use a component across multiple modules, you'll need to create a "shared" module and add that component the shared module's exports. Then you add that shared module into your other modules imports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM