title: Angular class inheritance, how to extend base class without injections inside child class
body: <p><strong>Angular 8</strong></p>
  
  <p>So the point of extending a base class is so child classes have methods provided by the parent class. However, base class needs some injections of various services. Those services are not needed by the chind classes. Example:</p>
  
  <pre><code>// The parent class which will be extended by the many children 
  export class parentClass {
    constructor(private service1: service1Service) {
    }
  
    protected action1(): any {
      return this.service1.someFunc();
    }
  
    public action2(): any {
      return this.service1.someFunc2();
    }
  }
  
  // One of the child classes which doesn't care about service1Service, but is required to inject it anyway...
  export class childClass extends parentClass {
    constructor(service1: service1Service) {
      super(service1);
    }
  
    public doSomething() {
      const data = this.action1();
      // bla bla bla
    }
  }
  </code></pre>
  
  <p>So the big problem is that every child class must inject that service1Service even tho they don't need it at all.</p>
  
  <p>My question is: is there a way to inject services inside parent class without requiring them to be injected inside childern? The example above is very simplified. In real situation parent class will have about 5 services injected. The parent class is going to be used by different team members who really should not care about services used there, because they are building their own classes on top of parent class and uses parent methods to retrieve data or perform calculations.</p>
  
  <p>I know there may be one semi good option:</p>
  
  <pre><code>import { Injector } from '@angular/core';
  export class parentClass {
    constructor(private injector: Injector) {}
    protected action1(): any {
      const s1 = this.injector.get(service1Service);
      return s1.someFunc();
    }
  }
  
  import { Injector } from '@angular/core';
  export class childClass extends parentClass {
    constructor(injector: Injector) {
      super(injector);
    }
  }
  </code></pre>
  
  <p>This way children only need to know to inject Injector and pass that to parent constructor. But i still want even cleaner solution, if possible.</p>