【发布时间】:2017-12-01 11:23:50
【问题描述】:
我有 3 个模块:AddressModule、CustomerModule 和 CustomerReportingModule。
AddressModule 有自己的路由和组件,负责为客户显示/编辑地址。它需要客户/客户 ID 来获取其数据。
CustomerModule 和 CustomerReportingModule 应该重用 AddressModule。
目前我正在考虑为我的 AddressModule 使用延迟加载,但这不是强制性的。
如何将客户/客户 ID 传递到 AddressModule 以便它可以加载其数据?
【问题讨论】:
-
如何将
customerId存储在应用程序的其余部分,例如CustomerModule和CustomerReportingModule? -
你不能直接使用路由吗?你在 AddressModule 中查看激活的路由并提取 CustomerID
-
@FredrikLundin - 我在两个模块中都有一个特定的商店,它知道选择了哪个客户。我考虑过使用这个商店,但 AddressModule 必须知道其他模块及其商店。
-
@Jan - 是的,这是一个选项,但我需要知道参数存在于哪个路由父级别,因此我知道我的 AdressModule 中的其他模块。
-
在模块级别添加的每个提供程序都将在应用程序范围内可用。这意味着如果您在
CustomerModule中提供商店,您也可以在AddressModule中注入它。仅供参考:)
标签: angular