1.0.3 • Published 6 years ago
config-lib v1.0.3
VSTS Configuration Service
Service loads your configuration on application initialization when calling loadConfig(). Allows you to have the ability to use Azure DevOps' token replacement with Angular project releases in different scopes.
Install
npm i config-lib
Usage
Import App.Module.ts:
import { ConfigLibService } from "config-lib";
Under providers:
{
'provide': APP_INITIALIZER,
'useFactory': init,
'deps': [ConfigLibService],
'multi': true
},
ConfigLibService
Still in App.Module.ts under export class AppModule() { }
export function init(configService: ConfigLibService) {
return () => configService.loadConfig();
}
This will set the config string on application initialization to be used later.
Create a client-config.json file under your assets folder.
{
"url": "https://example.com"
}
In any component/service you can call the ConfigLibService.configuration for the whole json configuration or ConfigLibService.getConfig("key") for a specific configuration value.
Finally add: "src/assets/client-config.json" under "assets" in the angular.json file.