Last active
November 5, 2020 17:08
-
-
Save ManuelDeLeon/e046b4645d68316fff4861c7f5ae500f to your computer and use it in GitHub Desktop.
This file contains 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: "app-add-numbers", | |
template: ` | |
<input type="number" [(ngModel)]="num1" /> + | |
<input type="number" [(ngModel)]="num2" /> | |
<button (click)="add()">Add</button> | |
<label>{{ result }}</label> | |
`, | |
}) | |
export class AppAddNumbersComponent { | |
num1 = 0; | |
num2 = 0; | |
result = 0; | |
add() { | |
this.result = this.sum(this.num1, this.num2); | |
} | |
sum(a: number, b: number) { | |
return a + b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment