gpt4 book ai didi

angular - 使组件可用于嵌套模块

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

所以现在我有一个看起来像这样的设置:

  • 应用模块
    • 一个大模块
      • 另一个大模块
        • 一个组件

A Component 无法访问 A Large Module 中加载的组件,即使这些组件被定义为 的声明导出一个大模块

有什么方法可以让嵌套模块 Another Large Module 访问 A Large Module 的组件导入,以便它的子组件可以访问那些组件?或者是否需要在 Another Large Module 中声明它们以便其子组件能够访问它们?

最佳答案

如果模块中声明的组件使用这些东西,则需要在模块中导入这些东西。您可以创建一个导入/导出/声明组件集的功能模块,并在您的其他模块中使用它。

- App Module
- FeatureA Module
- FeatureB Module
- Large Module (import FeatureA Module)
- Component [can use components from FeatureA;
can't use components from FeatureB]
- Another Large Module (import FeatureA Module, FeatureB Module)
- Component [can use components from FeatureA and FeatureB]

如果你的 Large ModuleAnother Large Module 是延迟加载的,你将在两个文件/包中都有 FeatureA module,但很少有额外的千字节不会受到伤害。一个额外的好处是可重用性,您可以在其他项目中使用功能模块:

- Different App Module
- FeatureA Module
- FeatureB Module
- Different Large Module (import FeatureA Module)
- Component [can use components from FeatureA;
can't use components from FeatureB]

关于angular - 使组件可用于嵌套模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40659710/

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