import { Component, OnInit, ViewChild, ElementRef, HostListener, Input } from '@angular/core'; @Component({ selector: 'bc-button-lib', templateUrl: './button-lib.component.html', styleUrls: ['./styles.scss'] }) export class ButtonLibComponent implements OnInit { // @ViewChild('colorLink', {static: false}) color: ElementRef; constructor(private el: ElementRef) { } @Input('bcHighlight') highlightColor: string; @HostListener('click') onClick(btn) { this.highlight(this.highlightColor || 'red'); } @HostListener('mouseenter') onMouseEnter() { this.highlight(this.highlightColor || 'red'); } @HostListener('mouseleave') onMouseLeave() { this.highlight(null); } ngOnInit(): void { } highlight(color: string) { this.el.nativeElement.style.backgroundColor = color; } }