angular - 解决 Angular 循环模块依赖和组件(父子)
问题描述
我有以下结构
Project
---Module1
------ComponentA
------componentB
---Module2
------componentC
------componentD
在导入中,Module1.module.ts
我正在导入 Module2,因为在componentA
我使用的componentC
属于Module2
.
现在,我需要componentB(Module1)
在我componentD
的 module2 中使用,但我有很多错误,因为我在导入时创建了循环依赖Module1
项Module2.module.ts
此时的结构是:Module1
is parent of Module2
。所以,我不知道是否存在某种方式来访问属于Module1(parent)
from one 中的一个组件的一个组件Module2(Child)
解决方案
如果您不关心当前的模块结构,您可以为组件 B 和 C 创建第三个模块 - 您可以导入module 3
到module 1
andmodule 2
中。
Project
---Module1
------ComponentA
---Module2
------componentD
---Module3
------componentC
------componentB
推荐阅读
- c++ - 调用“向量”没有匹配的函数
我有一个类 Registration,它从文件中读取第一行输入并将其发送到另一个类 Result 以特定方式读取其余部分。我想使用自定义矢量类来实现这一点。我将注册结果向量声明为私有变量,如下所示:
Vector<Result> results;
- jquery - 按字母分组字母列表并将组添加到无序列表
- c# - C# json 解析多个大括号内的字符串,不区分大小写
- r - 访问 `mutate_at` 中的列名以将其用于子集列表
- python - 如何防止多次出现带有选项的可选参数
- javascript - 如何在单击时显示/隐藏具有特定类的元素?
- python - 从 csv 读取到从 Dictionary 引用的 Dataframe
- ios - 如何将独立的 watchOS6 应用提交到 App Stoe Connect?
- linux - 查看按开始时间排序的所有进程运行
- android - 如何在 Flutter 的另一个提供程序类中将 Setter 用于提供程序类