title: singleton service error in app.module on ng build
body: <p>I am using a singleton service which will be shared across all components, I created a <strong>CoreModule</strong>, having a static class as:</p>
  
  <pre><code>static forRoot(config: GlobalServiceConfig): ModuleWithProviders {
      return {
        ngModule: CoreModule,
        providers: [
          { provide: GlobalServiceConfig, useValue: config }
        ]
      };
    }
  </code></pre>
  
  <p>in <strong>app.module.ts</strong></p>
  
  <pre><code>export declare var Globals: GlobalServiceConfig;
  export const g = Globals;
  </code></pre>
  
  <p><strong>Globals</strong> dict is created in index.html, value is coming from backend.
  now I am using this Globals variable in app.module.ts and provide this initial value to CoreModule.forRoot as:</p>
  
  <pre><code>imports: [
      BrowserModule,
      SharedModule,
      LoginModule,
      ShippingModule,
      PaymentModule,
      CoreModule.forRoot(g),
      AppRoutingModule,
    ],
  </code></pre>
  
  <p>on first ng build is failing, same with ng serve/watch but only for first time. if i make any changes the app is running fine as expected and getting the initial values also. but not able to build the app. The error states as:</p>
  
  <blockquote>
    <p>ERROR in Error encountered resolving symbol values statically. Only
    initialized variables and constants can be referenced because the
    value of this variable is needed by the template compiler (position
    29:20 in the original .ts file), resolving symbol Globals in
    E:/repos/emtex/mobilepayment/src/app/app.module.ts, resolving symbol g
    in E:/repos/emtex/mobilepayment/src/app/app.module.ts, resolving
    symbol AppModule in
    E:/repos/emtex/mobilepayment/src/app/app.module.ts, resolving symbol
    AppModule in E:/repos/emtex/mobilepayment/src/app/app.module.ts,
    resolving symbol AppModule in
    E:/repos/emtex/mobilepayment/src/app/app.module.ts</p>
  </blockquote>
  
  <p><strong>ng --version</strong></p>
  
  <pre><code>@angular/cli: 1.0.0
  node: 6.9.1
  os: win32 x64
  @angular/common: 4.0.0
  @angular/compiler: 4.0.0
  @angular/core: 4.0.0
  @angular/forms: 4.0.0
  @angular/http: 4.0.0
  @angular/platform-browser: 4.0.0
  @angular/platform-browser-dynamic: 4.0.0
  @angular/router: 4.0.0
  @angular/animations: 4.0.0
  @angular/cli: 1.0.0
  @angular/compiler-cli: 4.0.0
  </code></pre>