title: Angular2 // Why is DependencyInjection with Generics only working in Components?
body: <p>I have a service using generics that I would like to inject into another service like this</p>
  
  <pre><code>export class RestoreService&lt;T&gt;
  </code></pre>
  
  <p>Injection works in components like this</p>
  
  <pre><code>constructor(private restoreService: RestoreService&lt;Hero&gt;) {}
  </code></pre>
  
  <p>If I try to inject the same service into a non Component class I get an Exception saying "Cannot resolve all parameters for OtherService(?). Make sure they all have valid type or annotations."</p>
  
  <p>Here is a sample sample based on the hierarchical injection sample by angular.io
  <a href="http://plnkr.co/edit/wkj838xacI3cbOvz3qTs?p=preview" rel="nofollow">http://plnkr.co/edit/wkj838xacI3cbOvz3qTs?p=preview</a></p>
  
  <p>I also noticed that injecting multiple instances of RestoreService with different Ts results only in one instance being created. So I wonder if working with generic classes is a recommended pattern at all.</p>