title: Angular Service Injection Issue: @Injectable Doesn't Work but Providers Does
body: <p>I scanned through SO but couldn't find anything with my seemingly weird issue. I'll begin by copying in some of my code to give context:</p>
  
  <p>My Service:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  
  import { MyModule } from './my.module';
  
  @Injectable({
    providedIn: MyModule,
  })
  export class ApiService {
  
    // router: Router;
  
    constructor() {
      // this.router = MyModule.injector.get(Router);
    }
  ... Some methods ...
  }
  </code></pre>
  
  <p>My Module:</p>
  
  <pre><code>import { NgModule, Injector } from '@angular/core';
  import { CommonModule } from '@angular/common';
  import { RouterModule } from '@angular/router';
  import { ConnectionsListComponent } from './connections-list/connections-list.component';
  import { StoreModule } from '@ngrx/store';
  import * as fromMy from './reducers';
  import { routes } from './routes';
  ... component imports ...
  
  @NgModule({
    imports: [
      CommonModule,
      RouterModule.forChild(routes),
      StoreModule.forFeature('my', fromMy.reducers),
    ],
    declarations: [ConnectionsListComponent, MyShellComponentComponent, DashboardContainerComponent, DashboardElementComponent, DashboardElementInfoItemComponent],
    // providers: [ApiService]
  })
  export class MyModule {
  
    constructor() {
  
    }
  }
  </code></pre>
  
  <p>My Component:</p>
  
  <pre><code>import { Component, OnInit, Input } from '@angular/core';
  import { AttributeArrayHelperService } from '../attribute-array-helper.service';
  import { ApiService } from '../api.service';
  
  .. some interfaces ...
  
  @Component({
    selector: 'vz-dashboard-element',
    templateUrl: './dashboard-element.component.html',
    styleUrls: ['./dashboard-element.component.scss']
  })
  export class DashboardElementComponent implements OnInit {
  
    @Input() element: ElementInterface;
    @Input() erpType: String;
  
    equipmentAttributes: Object[] = []
  
    workOrderAttributes: Object[] = [
  
    ];
  
    constructor(private apiService: ApiService) {
  
     }
  
    ngOnInit() {
      const helper = new AttributeArrayHelperService();
      console.log(this.element);
      const lookupValues = helper.parseObjectArrayFor(this.element.Attributes, ['1', '2', '3']);
      console.log(lookupValues);
      const showValues = helper.parseArrayNames(lookupValues);
      console.log(showValues);
      console.log(this.apiService);
      console.log(this.apiService.getDashboardEntityInformation('4', '5', '6'));
      showValues.push();
      this.equipmentAttributes = showValues;
    }
  }
  </code></pre>
  
  <p>OK, so now that that's there here is my issue: When I am trying to use the @Injectable as I have it above, with the module declared, I get the following error in my browser but no TS compilation error (there is a circular ref warning though):</p>
  
  <blockquote>
    <p>DashboardContainerComponent.html:2 ERROR Error:
    StaticInjectorError(AppModule)[DashboardElementComponent ->
    ApiService]:    StaticInjectorError(Platform:
    core)[DashboardElementComponent -> ApiService]: 
        NullInjectorError: No provider for ApiService!</p>
  </blockquote>
  
  <p>When I change it to use @Injectable() and uncomment my providers it seems to like it and everything is fine. I'm just curious as to why this is? From reading the Angular documentation for 6.1 this seems to fit what is needed.</p>
  
  <p>For further information this is all inside a submodule and the service is meant to be isolated to this module. At this point, I'm just perplexed as to what I'm missing and as one of few JS people in my office, and the only using Angular, I don't have a second set of eyes to help me identify what I'm missing.</p>
  
  <p>Any help in doing so is GREATLY appreciated as this has been eating at me for a few days now. Thanks in advance,</p>
  
  <p>Steve</p>
  
  <p>Edit: Another thing to note is this was an app that was upgraded from 5 to 6. I followed the guide and got it all working, so maybe it sources from the upgrade?</p>