title: Angular 4 : SharedModule Causing Error
body: <p>i have a <strong>sharedModule</strong> that has a service called <strong>ConfigService</strong> and using the <strong>forRoot()</strong> pattern:</p>
  
  <p><strong>shared.module.ts:</strong></p>
  
  <pre><code>import { NgModule, ModuleWithProviders } from '@angular/core';
  import { CommonModule } from '@angular/common';
  import { ConfigService } from './config.service';// resolve ENV variable
  
  @NgModule({
    imports: [
      CommonModule
    ],
    declarations: [],
    providers:[]
  })
  export class SharedModule {
    static forRoot():ModuleWithProviders{
      return{
        ngModule:SharedModule,
        providers:[ConfigService]
      }
    }
   }
  </code></pre>
  
  <p><strong>app.module.ts</strong></p>
  
  <pre><code>@NgModule({
    declarations: [
      AppComponent,
    ],
    imports: [
      BrowserModule,
      FormsModule,
      HttpClientModule,
      SharedModule.forRoot(),
      AuthModule.forRoot()
    ],
    providers: [],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  
  <p><strong>when i'm trying to inject the ConfigService in another module Service
  (AuthModule -> AuthService) - i'm  receiving the following Error</strong></p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'forChild' of undefined
      at Object.cDNt (main.d647daef485a4cf9cf6d.bundle.js:1)
      at n (inline.7c624a7372e785c7b8fb.bundle.js:1)
      at Object.0 (main.d647daef485a4cf9cf6d.bundle.js:1)
      at n (inline.7c624a7372e785c7b8fb.bundle.js:1)
      at window.webpackJsonp (inline.7c624a7372e785c7b8fb.bundle.js:1)
      at main.d647daef485a4cf9cf6d.bundle.js:1
  </code></pre>
  
  <p><strong>AuthService.ts:</strong>:</p>
  
  <pre><code>@Injectable()
  export class AuthService {
    constructor(private http: HttpClient, private ConfigService:ConfigService) { 
  
    }
  </code></pre>
  
  <p>i can't resolve what causing this error.</p>