-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Moe Myat Zaw edited this page Jun 5, 2020
·
14 revisions
The ng-config
is a configuration and options service for Angular applications with flexible and extendable config providers.
npm
npm install @dagonmetric/ng-config
or yarn
yarn add @dagonmetric/ng-config
The following code is a simple module setup.
import { ConfigModule } from '@dagonmetric/ng-config';
import { HttpConfigProviderModule } from '@dagonmetric/ng-config/http-config-provider';
@NgModule({
imports: [
// Other module imports
// ng-config module
ConfigModule.init(),
HttpConfigProviderModule.withOptions({
endpoint: '/appsettings.json'
})
]
})
export class AppModule { }
import { Component } from '@angular/core';
import { ConfigService } from '@dagonmetric/ng-config';
export class IdentityOptions {
popupRedirectUri = ';
automaticSilentRenew = true;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
constructor(private readonly configService: ConfigService) {
// Get with key
const configValue = this.configService.getValue('key1'));
console.log('configValue: ', configValue);
// Get with options class
const identityOptions = this.configService.map(IdentityOptions));
console.log('identityOptions: ', identityOptions);
// Change detection
this.configService.valueChanges.subscribe(()=> {
const lastestOptions = this.configService.map(IdentityOptions));
console.log('lastestOptions: ', lastestOptions);
});
}
}
-
Discussions
-
Documentation
-
Integrations
-
Contributing