import { APP_INITIALIZER , NgModule } from "@angular/core" ; import { CommonModule } from "@angular/common" ; import { AppConfig } from "./app-config" ; import { HttpClientModule } from "@angular/common/http" ; /**
 * Management of central configuration for the app that can a set by an administrator independent of code
 * in the assets/config.json file.
 *
 * Just import this module in your root module to ensure the AppConfig is properly initialized on startup.
 *
 * You can then use the static `AppConfig.settings` object (which exactly represents the contents of the config.json)
 * to access the configuration values without need for dependency injection of a service.
 */ @ NgModule ( { imports : [ CommonModule , HttpClientModule ] , declarations : [ ] , providers : [ AppConfig , { provide : APP_INITIALIZER , useFactory : initializeAppConfig , deps : [ AppConfig ] , multi : true , } , ] , } ) export class AppConfigModule { } param appConfig export function initializeAppConfig ( appConfig ) { return ( ) => appConfig . load ( ) ; }