6

I am using the MsAdalAngular6Module, imported in AppModule and I need to be able to provide configuration values at runtime from an external json file:

@NgModule({
declarations: [AppComponent, HeaderComponent, SidebarComponent],
imports: [
CommonModule,
BrowserModule,
HttpClientModule,
MsAdalAngular6Module.forRoot( {tenant: config.tenantId,
  clientId: config.clientId,
  redirectUri: window.location.origin,
  endpoints: {
    string: ''
  },
  navigateToLoginRequestUrl: false,
  cacheLocation: 'localStorage'}),
AppRoutingModule

I'm running this in Docker, using multi-stage builds and nginx. Ideally, I'd like the default values for this modules config to come from the environment file, but should be superseded by values in an external json file at runtime.

I've seen several approaches to this, including Angular 2: External configuration befor bootstrap - passing the value to AppModule, but I can never seem to provide the values to app.module before it imports and configures the MsAdalAngular6 Module

Michael B
  • 61
  • 3
  • Have you checked out Angular APP_INITIALIZER? – Alexander Oct 04 '18 at 16:24
  • 1
    I have, specifically I read this: https://stackoverflow.com/questions/41619443/how-to-call-an-rest-api-while-bootstrapping-angular-2-app. This works well in components but I still don't understand how to access the value before my @NgModule declaration in app.module – Michael B Oct 04 '18 at 16:42

0 Answers0