Last active
June 6, 2019 23:17
-
-
Save arturovt/eed61e959eddeba3ddbd924e64324d39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { Component, ChangeDetectionStrategy, Input, ElementRef } from '@angular/core'; | |
@Component({ | |
selector: 'app-button', | |
templateUrl: './button.component.html', | |
styleUrls: ['./button.component.scss'], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class ButtonComponent { | |
@Input() | |
public color: string = null; | |
@Input() | |
public shouldEmit = false; | |
constructor(private host: ElementRef<HTMLElement>) {} | |
public click(): void { | |
if (this.shouldEmit) { | |
this.host.nativeElement.dispatchEvent( | |
new CustomEvent('click') | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment