Last active
July 23, 2017 20:12
-
-
Save wKoza/047df320b7c8250f92212d29aed2e7af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Directive, Renderer2, ElementRef, HostListener} from '@angular/core'; | |
@Directive({ | |
selector: '[appHighlight]' | |
}) | |
export class HighlightDirective { | |
constructor(el: ElementRef, renderer: Renderer2) { | |
renderer.setStyle(el.nativeElement, 'color', 'red'); | |
} | |
@HostListener('mouseenter', ['$event']) onMouseEnter(event: Event) { | |
console.log('mouseenter'); | |
console.log(event); | |
} | |
@HostListener('mouseleave', ['$event']) onMouseLeave(event: Event) { | |
console.log('mouseleave'); | |
console.log(event); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment