Hi, today I will explain how to use the HostListener decorator easily.
First, this decorator we use for:
This decorator is listening for a specific event by the host element
Go to the code example:
Each time you click inside the component, the counter will increase by 1
@HostListener("click", ["$event"])
onClickEvent(event: Event) {
this.clicksCounts += 1;
}
If you want to know all the events that you can play with HostListener you can see it in w3school list here ->[https://www.w3schools.com/jsref/dom_obj_event.asp]
Top comments (0)