The @HostListener has two parameters. The first is the name of the host event we would like to listen. For our use case, it will be the window:keyup event. The second parameter takes a list of arguments returned by the event you are listening.
In Angular, you do this using @HostListener(). To understand @HostListener() in a better way, consider another simple scenario: on the click of the host element, you want to show an alert window.
I am using a hostlistener in a directive to detect "blur"- and "keyup"-events. Now I need to detect changes in the input-element the directive sits on.
Post a Comment:
Showing 0 Comments: