Skip to content

Instantly share code, notes, and snippets.

@ManuelDeLeon
Last active November 5, 2020 17:08
Show Gist options
  • Save ManuelDeLeon/e046b4645d68316fff4861c7f5ae500f to your computer and use it in GitHub Desktop.
Save ManuelDeLeon/e046b4645d68316fff4861c7f5ae500f to your computer and use it in GitHub Desktop.
import { Component } from "@angular/core";
@Component({
selector: "app-add-numbers",
template: `
<input type="number" [(ngModel)]="num1" /> +
<input type="number" [(ngModel)]="num2" />&nbsp;
<button (click)="add()">Add</button>&nbsp;
<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