Skip to content

Instantly share code, notes, and snippets.

@gumpnart
Last active January 15, 2017 07:48
Show Gist options
  • Select an option

  • Save gumpnart/590ad8b1223760cb8ba5af9b6fc3271c to your computer and use it in GitHub Desktop.

Select an option

Save gumpnart/590ad8b1223760cb8ba5af9b6fc3271c to your computer and use it in GitHub Desktop.
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'child-component',
template: `
<span>{{ value1 + ' + ' + value2 }}</span> &nbsp;
<button type="button" (click)="onCalculate()"> calculate </button>
`,
})
export class ChildComponent {
@Input() value1: number;
@Input() value2: number;
@Output() calculate: EventEmitter<number> = new EventEmitter();
constructor() { }
onCalculate(){
this.calculate.emit(this.value1 + this.value2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment