title: Injection of Generic Services in Angular
body: <p>Will Angular inject more than one instance of a generic Service if it is invoked across Component constructors using different Types?</p>
  
  <p>I have a lot of Services that are going to provide the same functionality for different classes that all inherit from the same base class. I'd like to use Typescript's generic pattern <code>MyService&lt;T extends BaseClass&gt;</code> to handle this. </p>
  
  <p>But I don't know how it jives with Angular's injector:</p>
  
  <ol>
  <li>Will the Angular injector create <em>more than one instance</em> of this service if it's injected into different components with different Types?</li>
  <li>Will the injector inject the <em>same instance</em> if it is called with the same type?</li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>@Injectable
  export class MyService&lt;T&gt; {
      ...
  }
  
  @Component
  export class ComponentA {
      constructor(alphaService MyService&lt;Alpha&gt;) {}   &lt;--Instance 1
  }
  
  @Component
  export class ComponentB {
      constructor(betaService MyService&lt;Beta&gt;) {}   &lt;----Instance 2?
  }
  
  @Component
  export class ComponentA1 {
      constructor(alphaService MyService&lt;Alpha&gt;) {}  &lt;---Instance 1?
  }
  </code></pre>
  
  <p>Is this legal?  Does the injector know to create two instances of MyService?</p>