my solution utilizing a Directive:
--HTML
custom-button.component.html
<button class="btn btn-danger" style="width: 110px" customButton"
></button>
--TypeScript
custom-button.directive.ts
@Directive({
selector: '[customButton]'
})
export class CustomButtonDirective implements OnInit {
constructor(private elRef: ElementRef, private renderer: Renderer2) {
}
ngOnInit() {
}
@HostListener('mousedown') onmousedown(eventData: Event) {
if (this.elRef.nativeElement.style.backgroundColor === 'blue') {
this.renderer.setStyle(this.elRef.nativeElement, 'background-color', 'rgba(200,0,0,0.7)');
} else {
this.renderer.setStyle(this.elRef.nativeElement, 'background-color', 'blue');
}
}