装饰器 @HostListener

  @HostListener('mouseenter') onMouseEnter() {
    this.highlight(this.hight||'red');
  }

  @HostListener('mouseleave') onMouseLeave() {
    this.highlight(null);
  }
  private highlight(color: string) {
    this.el.nativeElement.style.backgroundColor = color;
  }
posted @ 2017-06-25 05:21  judy201654321  阅读(398)  评论(0编辑  收藏  举报