DEV Community

Discussion on: Nobody has to use HostListener

Collapse
 
bespunky profile image
Shy Agam

It is probably better to use Renderer2 for listening instead of directly accessing the native element.

Collapse
 
tieppt profile image
Tiep Phan

I think so. Renderer2 have listen method to do that.

Collapse
 
niklas_wortmann profile image
Jan-Niklas Wortmann

Oh thanks a lot for this feedback. I didn't know that before. I'll update the blog post today

Collapse
 
agroupp profile image
Arthur Groupp

Renderer2 listen method doesn't have params that have addEventListener. Actually it's the same as @HostListener.