In Angular, the @HostListener() function decorator allows you to handle events of the host element in the directive class. Let’s take the following requirement: when you hover mouse on the host element, only the color of the host element should change. In addition, when the mouse i...
HoverDirectiveis in thedeclarationsarray in theAppModule, which means that it can be used in the components in the module. Next, inhover.directive.ts, we write: import{Directive,ElementRef,HostListener,Input}from"@angular/core";@Directive({selector:"[appHover]",})exportclassHoverDirective{@Input...