title: HttpClient instance is undefined in Angular 6 service
body: <p>I have a service that wraps <code>HttpClient</code>. That service is called by a component. The problem is that when I inject the service in the component constructor it is <code>undefined</code>. Moreover, the service constructor seems to not execute at all as a <code>console.log</code> does not print anything. Any ideas?</p>
  
  <pre><code>@Injectable({
    providedIn: 'root'
  })
  export class MyHttpService {
  
    constructor(public httpx: HttpClient) {
          console.log("in the constructor - " + this.httpx) // &lt;-- this is never printed
    }
  
    call () {
          let reqData = { act: 'R'};
          this.httpx.post('/myurl', reqData).subscribe(result =&gt; {
              console.log(result);
            }, error =&gt; console.log('There was an error: '));
      }
  }
  </code></pre>
  
  <p>The related module is defined as follows:</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { CommonModule } from '@angular/common';
  import { HttpClientModule } from '@angular/common/http';
  import { HttpClient } from '@angular/common/http';
  import { MyHttpService } from './http.service';
  
  @NgModule({
    imports: [
      CommonModule,
      HttpClientModule, 
      HttpClient
    ],
    declarations: [
      MyHttpService
    ],
    exports: [
      MyHttpService
    ]
  })
  export class CoreServiceModule {}
  </code></pre>
  
  <p>The component that calls the service:</p>
  
  <pre><code>@Component({
        selector: 'some-selector',
        templateUrl: 'some-url.html'
      })
  export class MyComponent implements OnInit{ 
  
      constructor(public http:MyHttpService){
            console.log(http);  // &lt;-- this prints undefined
      }
  
      ngOnInit() {
          let x = this.http.call();  // &lt;-- this fails as http is undefined       
      }
  
  
  }
  </code></pre>
  
  <p>And the component module:</p>
  
  <pre><code>@NgModule({
    declarations: [MyComponent],
    exports: [MyComponent],
    imports: [BrowserModule, CoreServiceModule],
    bootstrap: [MyComponent]
  })
  export class MyModule {}
  </code></pre>