Skip to content

Instantly share code, notes, and snippets.

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

  • Save gumpnart/941c380adba22b1b570bc670b0808893 to your computer and use it in GitHub Desktop.

Select an option

Save gumpnart/941c380adba22b1b570bc670b0808893 to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
@Component({
selector: 'parent-component',
template: `
<input type="number" min="0" name="num1" m [(ngModel)]="num1"> <span>+</span>
<input type="number" min="0" name="num2" [(ngModel)]="num2"><br><br>
<app-child-component [value1]="num1" [value2]="num2" (calculate)="result($event)"></app-child-component>
<p>{{ 'Result is ' + resultValue }}</p>
`,
})
export class ParentComponent {
num1: number = 0;
num2: number = 0;
resultValue: number = 0;
constructor() { }
ngOnInit() {
}
result(value){
this.resultValue = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment