SekibOmazic / angular2-playground

MIT License
71 stars 7 forks source link

remove useless hostlisteners #3

Closed ludohenin closed 9 years ago

SekibOmazic commented 9 years ago

@ludohenin Thanks!

ludohenin commented 9 years ago

I'm not quite sure what the real use of hostListeners though :) any idea ?

SekibOmazic commented 9 years ago

I used them before like this:

@Component({
  selector: 'drag',
  hostListeners: {
    'mousedown': 'onMouseDown($event)'
  }
})

but now I prefer:

<div class="item" (mousedown)="onMouseDown($event)">

so I'm not really sure what is the real purpose :-)

ludohenin commented 9 years ago

yeah OK, that's what I was thinking, thanks.

ibhi commented 9 years ago

I think host listeners is provided as a high level api for the DOM, without touching the DOM. To better understand there was one example from victor savkin victorsavkin.com/post/118372404541/the-core-concepts-of-angular-2 , refer the heading hostelement

ibhi commented 9 years ago

Also you can have a look at example 3, in my article here, where I have setup hostListeners to fire custom event.