title: How to inject directive of subclass into component
body: <p>I have a component that should change its behavior depending on what directive is added to the element. This custom logic are defined in the directives so the component needs not be modified when a new scope/feature is added.</p>
  <pre><code>MyComponent
  MyDirectiveBase
  MyDirective1 extends MyDirectiveBase
  MyDirective2 extends MyDirectiveBase
  </code></pre>
  <p>In the component constructor, I want to inject the directive that is applied to the element. I can do this without issue when I know the exact class that will be used, but what I want is any directive that extends from MyDirectiveBase.</p>
  <p><strong>How can I tell the DI-framework to allow all subclasses of MyDirectiveBase?</strong></p>
  <p>I have tried using an injection token (with multi=true), but that just gave me an array of the classes/functions, not the element instance. Also if no attribute is specified, no directive should be injected.</p>
  <p>Sample repo:
  <a href="https://github.com/ulvesked/angular-dependency-inject-directive-subclass-to-component" rel="nofollow noreferrer">https://github.com/ulvesked/angular-dependency-inject-directive-subclass-to-component</a></p>
  <p>StackBlitz: <a href="https://stackblitz.com/edit/angular-ivy-bihzjv?devtoolsheight=33&amp;file=src/app/app.component.html" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-ivy-bihzjv?devtoolsheight=33&amp;file=src/app/app.component.html</a></p>