2

I was wondering what's the difference between doing :

@Directive({
  selector: 'input',
  host: {
    '(window:resize)': 'onResize($event)'
  }
})
class InputDirective {
  onResize(event:Event) {
     ...
  }
}

and

@Directive({
  selector: 'input'
})
class InputDirective {
  @HostListener('window:resize', [$event])
  onResize(event:Event) {
     ...
  }
}
Scipion
  • 11,449
  • 19
  • 74
  • 139
  • 4
    See also http://stackoverflow.com/questions/41318575/angular-2-typescript-input-output-or-input-output and http://stackoverflow.com/questions/40661325/why-is-input-decorator-preferred-over-inputs – yurzui Dec 27 '16 at 09:41
  • After going through the questions mentioned by @yurzui, prefer '@HostListener' over `host` as in angular style guide ? – Gangadhar Jannu Apr 08 '17 at 19:19

0 Answers0