Skip to content

Instantly share code, notes, and snippets.

@bniedermeyer
Last active June 3, 2018 18:40
import { Component, OnInit, EventEmitter, Output } from '@angular/core';
@Component({
selector: 'lib-counter-button',
templateUrl: './counter-button.component.html',
styleUrls: ['./counter-button.component.css']
})
export class CounterButtonComponent implements OnInit {
@Output() countChanged: EventEmitter<number> = new EventEmitter();
clickCount = 0;
constructor() {}
ngOnInit() {}
/**
* Increments the count when the button is clicked and emits an event
* to notify parent component of new count value
*/
handleButtonClick() {
this.clickCount++;
this.countChanged.emit(this.clickCount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment