Skip to content

Instantly share code, notes, and snippets.

@debugmodedotnet
Created January 2, 2018 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugmodedotnet/35341e8c4ed4dcd4b048f6d60c237576 to your computer and use it in GitHub Desktop.
Save debugmodedotnet/35341e8c4ed4dcd4b048f6d60c237576 to your computer and use it in GitHub Desktop.
import { Component, EventEmitter, Output } from '@angular/core';
@Component({
selector: 'app-child',
template: `<button class='btn btn-primary' (click)="valueChanged()">Click me</button> `
})
export class AppChildComponent {
@Output() valueChange = new EventEmitter();
Counter = 0;
valueChanged() { // You can give any function name
this.counter = this.counter + 1;
this.valueChange.emit(this.counter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment