Skip to content

Instantly share code, notes, and snippets.

@wKoza
Last active October 21, 2016 18:30
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 wKoza/c4922a665cf776998bc755ce1eaa2890 to your computer and use it in GitHub Desktop.
Save wKoza/c4922a665cf776998bc755ce1eaa2890 to your computer and use it in GitHub Desktop.
import {Component, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-comp2',
template: `
<button (click)="decrement()" > - </button>
<button (click)="increment()"> + </button>
`
})
export class Comp2Component {
counterValue: number = 0;
@Output() counterChange = new EventEmitter();
increment() {
this.counterValue++;
this.counterChange.emit({
value: this.counterValue
});
}
decrement() {
this.counterValue--;
this.counterChange.emit({
value: this.counterValue
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment