将参数传递到模块 [英] Pass Parameter into Modules

查看:95
本文介绍了将参数传递到模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个模块:AddressModule,CustomerModule和CustomerReportingModule.

I have 3 modules: AddressModule, CustomerModule and CustomerReportingModule.

AddressModule具有自己的路由和组件,并负责显示/编辑客户的地址.它需要customer/customerId来获取其数据.

AddressModule has its own routes and components and is responsible for displaying/editing an address for a customer. It needs the customer/customerId to fetch its data.

CustomerModule和CustomerReportingModule应该重用AddressModule.

CustomerModule and CustomerReportingModule should reuse AddressModule.

当前,我正在考虑对我的AddressModule使用延迟加载,但这不是强制性的.

Currently I was thinking to use lazy loading for my AddressModule but this is not mandatory.

如何将customer/customerId传递到AddressModule中,以便它可以加载其数据?

How can I pass in the customer/customerId into the AddressModule so it can load its data?

推荐答案

为什么不使用服务在这些模块之间共享数据.您可以在主模块提供者处导入此服务,从而可以在所有其他模块中使用该服务并共享数据.

Why don't you use service to share the data between those modules. You can have this service, imported at the main module provider and hence can be used in all other modules and share the data.

该服务可以具有设置和获取值的功能,因此您可以在服务中使用这些功能来获取所需的数据

The service can have functions to set and get values and hence you can make use of these functions in services to get your required data

这篇关于将参数传递到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆