I'm developing an app in Angular 2 in which I have a parent component and child component. The child component has a HostListener of keydown event and executes some functionality. I'm able to achieve this, but the problem is if I press any key in context of the parent component then HostListener also executes. What I want is HostListener to execute if I'm in context of the child component.
This is not working as I intend to. It is in child Component
@HostListener('keydown', ["$event"])
ondropdown(){ functionality }
This is working but on the whole page, I even tried 'window' but the effect is same.
@HostListener('document:keydown', ["$event"])
ondropdown(){ //functionality }
in context of Parent component? - Max Koretskyi