title: angular keyup event does not trigger on child component, but only on parent instead
body: <p>I created a component that i wish to have multiple versions of it in my app, since i want to keep all the logic in only one place, i created a ParentComponent where all my code resides.</p>
  
  <p>But angular dont inherit component annotations, so i created also a "TemplateComponent", to prevent code duplication. The TemplateComponent holds the input, but it's the ParentComponent that handles the events from the input. That way, every ChildComponent, inherits ParentComponent for the logic, and it's template is a instance of TemplateComponent.</p>
  
  <p>The big deal, is that when i try to listen to keyup event on the input inside TemplateComponent, the click event is being called on ChildComponent, who dont have any inputs or controls. </p>
  
  <p>I've tryed to pass an event binding to template component to connect the keyup input, but it never triggers.</p>
  
  <p>There's a HostListener on the ChildComponent, just to debug that the event is only being triggered there. And it's not that that's causing the event to stop there.</p>
  
  <p>Is there a way to tell angular that the keydown event must be called inside the template component, or another way of linking everything toghether ?</p>
  
  <p>I got a working plunker, it's pretty much self-explanatory:</p>
  
  <p><a href="https://plnkr.co/edit/e4U6DB4d47ULpLppHd4H?p=preview" rel="nofollow noreferrer">https://plnkr.co/edit/e4U6DB4d47ULpLppHd4H?p=preview</a></p>
  
  <p>But also the code:</p>
  
  <p>ParentComponent:</p>
  
  <pre><code>import {Component, NgModule, VERSION} from '@angular/core'
  
  @Component({
    selector: 'app-parent',
    template: `
      &lt;ng-content&gt;&lt;/ng-content&gt;
    `,
  })
  export class ParentComponent {
  
    printText = 'Not yet';
  
    constructor() {
    }
  
    inputKeyDownEnter(event: any) {
      this.printText = 'KeyDown OK!';
    }
  
    clearButtonClick(event: any) {
      this.printText = "Clear button click!";
    }
  }
  </code></pre>
  
  <p>ChildComponent:</p>
  
  <pre><code>import {Component, HostListener} from '@angular/core';
  import {ParentComponent} from './parent.component';
  
  @Component({
    selector: 'app-child',
    template: `
      &lt;div&gt;{{printText}}&lt;/div&gt;
      &lt;app-custom-template
        (inputKeyDownEnter)="inputKeyDownEnter"
        (clearButtonClick)="clearButtonClick"
      &gt;
      &lt;/app-custom-template&gt;
    `,
  })
  export class ChildComponent extends ParentComponent {
  
    constructor() {
      super();
    }
  
    @HostListener('keydown.enter', ['$event'])
    onKeyDownChild(event: any) {
      console.log('Only here :( !');
    }
  
  }
  </code></pre>
  
  <p>TemplateComponent:</p>
  
  <pre><code>import {Component, Output, EventEmitter} from '@angular/core';
  
  @Component({
    selector: 'app-custom-template',
    template: `
      &lt;input 
        type="text"
        name="my_text"
        (keyup.Enter)="inputKeyDownEnter.emit($event)"
        /&gt;
      &lt;button
        type="button"
        (click)="clearButtonClick.emit($event)"&gt;Clear&lt;/button&gt;
    `,
  })
  export class CustomTemplateComponent {
  
    @Output()
    inputKeyDownEnter = new EventEmitter&lt;any&gt;();
  
    @Output()
    clearButtonClick = new EventEmitter&lt;any&gt;();
  
    constructor() {
    }
  
  }
  </code></pre>