Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

typescript - angular - use ngx-config in module

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...