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

标签 angular typescript

我想在我的 Angular 2 应用程序的两个单独的模块中包含一个共享组件“SimpleRadialChartComponent”。当我在每个模块的声明区域中传递此组件时,出现以下错误:

类型 SimpleRadialChartComponent 是 2 个模块声明的一部分

如何在两个不同的模块中声明共享组件?

最佳答案

好的做法是为两个或多个模块中使用的组件、模型对象等创建“共享”模块。

您可以在 official documentation 中找到所有指南和良好实践.


您的问题的详细描述,您可以找到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.

关于angular - 类型 Y 是 2 个模块声明的一部分 - Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43347640/

相关文章:

Angular 8 UI observable 不触发更改检测 - ChangeDetectionStrategy 设置为默认值

html - angular2 - 使用 flexbox 设置组件的高度

node.js - 让 ngPrime 为 Angular 2 工作

typescript - Angular2 RC4 路由器 : Get the RouteConfigs "data"-Property from Router-Events Subscription in a Service

javascript - 如何使用 nativeElement.focus() 与 ngFor 中的每个唯一输入以 Angular

angular - 类型 'zip' 上不存在属性 'typeof Observable'。 Angular 6

angular - 在 Angular 6 应用程序上向下滚动时删除粘性类?

javascript - AngularX TS 错误无法调用类型缺少调用签名的表达式

node.js - 如何在 Typescript 的方法装饰器上创建编译错误?

typescript - atom-typescript 提示 tsconfig.json——我怎样才能自动创建一个?