gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 21:19:58 24 4
gpt4 key购买 nike

我想在我的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com