Angular 6 Services and Class Inheritance : <p>Angular 6 now has <a href="https://angular.io/guide/dependency-injection#injectable-providers" rel="noreferrer">injectable providers</a> which is the new recommended way of injecting services, and it works really well except I'm having a problem when using a service which extends another service.  So as an example, suppose I have</p>

<pre><code>@Injectable({
  providedIn: 'root'
})
export class ParentAppService { ... }

@Injectable({
  providedIn: 'root'
})
export class ChildAppService extends ParentAppService { ... }
</code></pre>

<p>The problem is that no matter what I ask for in a component, the parent class is always injected.</p>

<p>So if you ask for</p>

<pre><code>constructor(private childAppService: ChildAppService) { ... }
</code></pre>

<p>you will still be provided an instance of ParentAppService, which isn't expected.</p>

<p>A very simple workaround would be to just register the providers in your module the old fashioned way, and this works:</p>

<pre><code>@NgModule({
 providers: [AppService, ChildAppService]
})
</code></pre>

<p>But that's basically the old way of doing things, and doesn't have the benefits of better tree-shaking and cleaner testing like the new providedIn registration process.</p>

<p>So my question is, what's the right way to do this?  Is there a better way to register a provider so I can get the desired behavior (maybe specifying a provider token somehow?).</p>

<p>I've setup a super simple stackblitz example to show what's going on.  </p>

<p><a href="https://stackblitz.com/edit/angular-lacyab?file=src%2Fapp%2Fapp.component.ts" rel="noreferrer">https://stackblitz.com/edit/angular-lacyab?file=src%2Fapp%2Fapp.component.ts</a></p>

<p>You'll notice it says "Hello I AM APP SERVICE!" even though the component asked to be provided the child service.  If in the app module we register the providers the old way (see the commented out code), all of a sudden the proper provider gets injected.</p>

<p>Thanks for your help!</p>
