In my angular project all the configuration values exist in an external file(localhost/8092/actuator/info
) so i used @ngx-config
to read from this file.
Now i have the FrontCommonModule
module that gets as parameter a config of type ConfigInterface
, in the below example the values of the attributs is static. How can i get the values of the attributs from the extenral file ?
app.module.ts
export function configFactory(http: HttpClient): ConfigLoader {
let infoUrl = window.location.protocol + '//' + window.location.hostname + ':8092/actuator/info';
if ((window.location.port == null) || (window.location.port === '')) {
infoUrl = window.location.protocol + '//' + window.location.hostname + '/actuator/info';
}
return new ConfigHttpLoader(http, infoUrl);
}
export const config: ConfigInterface = {
production: false,
staticPath: '',
env: 'dev',
mocked: false,
mockAuth: false,
hmr: true,
clientIdRoles: 'adminback',
apiAdminbackUrl: 'http://xxxxxx/api/',
apiParambackUrl: 'http://yyyyyy/api',
appSelectorUrl: 'http://wwwwwww/'
};
@NgModule({
imports: [
FrontCommonModule.forRoot(config),
ConfigModule.forRoot({
provide: ConfigLoader,
useFactory: configFactory,
deps: [HttpClient]
})
]
)}
question from:
https://stackoverflow.com/questions/65920141/angular-use-ngx-config-in-module 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…