title: Run JwtModule factory after APP_INITIALIZER has resolved
body: <p>Im trying to load the &quot;allowedDomains&quot; property for the <code>JwtModule</code> of <a href="https://github.com/auth0/angular2-jwt" rel="nofollow noreferrer"><code>@auth0/angular-jwt</code></a> from a configuration service.
  I already have an <code>AppConfigurationService</code> which runs as <code>APP_INITIALIZER</code> that will generate the needed value.
  For the <code>JwtModule</code>, I use a factory to generate the configuration. I want this factory to access the <code>AppConfigurationService</code> and get the appropriate value. The problem is that the JWT factory runs before <code>loadConfig</code> resolves.</p>
  <p>AppConfigurationService.ts:</p>
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  
  @Injectable({
    providedIn: 'root'
  })
  export class AppConfigurationService {
  
    public allowedHost: string;
  
    constructor(private http: HttpClient) {
    }
  
    load(): Promise&lt;any&gt; {
      // loads JSON from a server and generates configuration out of that
      // returns a Promise since it uses Angulars HttpClient
    }
  }
  </code></pre>
  <p>app.module.ts:</p>
  <pre><code>import { APP_INITIALIZER, NgModule } from '@angular/core';
  import { AppRoutingModule } from './app-routing.module';
  import { AppComponent } from './app.component';
  import { HttpClientModule } from '@angular/common/http';
  import { JWT_OPTIONS, JwtModule } from '@auth0/angular-jwt';
  import { AppConfigurationService } from './shared/configuration/app-configuration.service';
  // ...
  
  
  export function tokenGetter(): string {
    // returns the token for JWT
  }
  
  /**
   * Loads the app configuration via the AppConfigurationService
   */
  export function loadConfig(configurationService: AppConfigurationService): () =&gt; Promise&lt;any&gt; {
    return () =&gt; configurationService.load();
  }
  
  /**
   * Factory for generating the configuration for the JwtModule.
   */
  export function jwtConfigurationFactory(configurationService: AppConfigurationService): {} {
    return {
      tokenGetter,
      headerName: 'Authorization',
      authScheme: 'Bearer ',
      allowedDomains: [configurationService.allowedHost],
      skipWhenExpired: false,
    };
  }
  
  @NgModule({
    declarations: [AppComponent],
    imports: [
      // ...
      JwtModule.forRoot({
        jwtOptionsProvider: {
          provide: JWT_OPTIONS,
          useFactory: jwtConfigurationFactory,
          deps: [AppConfigurationService]
        },
      }),
    ],
    providers: [AppConfigurationService, {
      provide: APP_INITIALIZER,
      useFactory: loadConfig,
      multi: true,
      deps: [AppConfigurationService]
    }],
    bootstrap: [AppComponent],
  })
  export class AppModule {}
  
  </code></pre>
  <p>Does anyone know how to make the <code>jwtConfigurationFactory</code> wait for <code>loadConfig</code> to resolve?</p>