pau-riquelme

Untitled

Nov 23rd, 2017
4,646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Directive, ElementRef, HostListener, Input } from '@angular/core';
  2.  
  3. @Directive({
  4.     selector: '[appMyFirstDirective]'
  5. })
  6. export class MyFirstDirectiveDirective {
  7.  
  8.     @Input() appMyFirstDirective:string;
  9.  
  10.     constructor(private element: ElementRef){}
  11.  
  12.     @HostListener('mouseenter')
  13.     public onMouseEnter(){
  14.         this.element.nativeElement.style.backgroundColor = this.appMyFirstDirective;
  15.     }
  16.  
  17.     @HostListener('mouseleave')
  18.     public onMouseLeave(){
  19.         this.element.nativeElement.style.backgroundColor = '';
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment