Created
January 15, 2017 07:48
-
-
Save gumpnart/941c380adba22b1b570bc670b0808893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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