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> | |
| `, |
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, Input, Output, EventEmitter } from '@angular/core'; | |
| @Component({ | |
| selector: 'child-component', | |
| template: ` | |
| <span>{{ value1 + ' + ' + value2 }}</span> | |
| <button type="button" (click)="onCalculate()"> calculate </button> | |
| `, | |
| }) | |
| export class ChildComponent { |
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> | |
| <child-component [value1]="num1" [value2]="num2"></child-component> | |
| `, | |
| }) |
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, Input } from '@angular/core'; | |
| @Component({ | |
| selector: 'child-component', | |
| template: ` | |
| <span>{{ value1 + ' + ' + value2 }}</span> | |
| ` | |
| }) | |
| export class ChildComponent { | |
| @Input() value1: number; |