Angular: 如何使用参数初始化模块(或服务)?
Angular: how do I init module (or service) with parameters?
我需要创建一个将由不同应用程序使用的模块。
每个应用程序都使用自己的一组变量(应用程序名称、REST URL 等)。
如何通过托管应用程序在模块(或服务)中设置内部变量?
需要在应用程序加载时尽快初始化这些参数。
谢谢。
在你的模块中有一个提供者。这样客户端应用程序就可以 bootstrap 配置。
请阅读 angular's site 上的 "Provider Recipe" 部分以获取相关示例。
You should use the Provider recipe only when you want to expose an API for application-wide configuration that must be made before the application starts. This is usually interesting only for reusable services whose behavior might need to vary slightly between applications.
我需要创建一个将由不同应用程序使用的模块。 每个应用程序都使用自己的一组变量(应用程序名称、REST URL 等)。
如何通过托管应用程序在模块(或服务)中设置内部变量?
需要在应用程序加载时尽快初始化这些参数。
谢谢。
在你的模块中有一个提供者。这样客户端应用程序就可以 bootstrap 配置。
请阅读 angular's site 上的 "Provider Recipe" 部分以获取相关示例。
You should use the Provider recipe only when you want to expose an API for application-wide configuration that must be made before the application starts. This is usually interesting only for reusable services whose behavior might need to vary slightly between applications.