<p highlightMouse>
Texto com highlight quando passo o mouse.
</p>
import { Directive, HostListener, HostBinding, ElementRef, Rendeder } from '@angular/core';
@Directive({
selector: '[highlightMouse]'
})
export class HighlightMouseDirective {
@HostListener('mouseenter') onMouseOver() {
this.backgroundColor = 'yellow';
}
@HostListener('mouseleave') onMouseLeave() {
this.backgroundColor = 'white';
}
//Host Binding
@HostBinding('style.backgroundColor') backgroundColor: string;
constructor(){}
}