Skip to content

Instantly share code, notes, and snippets.

@arturovt
Created June 6, 2019 23:14
Show Gist options
  • Save arturovt/c1daaedf10a360c504755d7af3cd3691 to your computer and use it in GitHub Desktop.
Save arturovt/c1daaedf10a360c504755d7af3cd3691 to your computer and use it in GitHub Desktop.
import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } 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;
@Output()
public click = new EventEmitter<void>();
public onClick(): void {
if (this.shouldEmit) { // This is just a rough example
this.click.emit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment