简体   繁体   English

类型Y是2个模块的声明的一部分-Angular 2

[英]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. 我想在我的angular 2应用程序的两个单独的模块中包含一个共享组件“ SimpleRadialChartComponent”。 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 类型SimpleRadialChartComponent是2个模块的声明的一部分

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. 然后,您将该共享模块添加到其他模块导入中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型“ LocationComponent”是2个模块的声明的一部分:角6? - Type “LocationComponent” is part of the declarations of 2 modules:Angular 6? 组件是 Angular 中 2 个模块声明的一部分 - Component is part of the declarations of 2 modules in Angular 类型X是2个模块声明的一部分(Angular 2 RC5) - Type X is part of the declarations of 2 modules (Angular 2 RC5) 角度错误:“是2个模块的声明的一部分(相同)” - Angular Error: “is part of the declarations of 2 modules (same)” Angular 7.2-“组件是2个模块的声明的一部分”,但不是 - Angular 7.2 - “component is part of the declarations of 2 modules” but it is not 类型页面是 2 个模块错误声明的一部分 - Type page is part of the declarations of 2 modules error 类型 LeadPage(Module) 是 2 个模块声明的一部分 - Type LeadPage(Module) is part of the declarations of 2 modules 错误:类型组件是 2 个模块声明的一部分 - Error: Type Component is part of the declarations of 2 modules 角2:类型ChildComponent是以下两个模块的声明的一部分:parent1Module和Parent2Module - Angular 2 : Type ChildComponent is a part of the declarations of 2 modules : parent1Module and Parent2Module HMR 因 Angular 9 + IVY 失败:类型 AppComponent 是 2 个模块声明的一部分:AppModule 和 AppModule - HMR fails with Angular 9 + IVY: Type AppComponent is part of the declarations of 2 modules: AppModule and AppModule
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM