0
Some of you may have seen that I’ve been doing angular study since the zero... I thought of making a calculator using a dropdown to already work the Binding features
The point is I can’t get the value to get to the screen:
import { Component } from '@angular/core';
@Component({
selector: 'app-modulo-fixacao',
templateUrl: './modulo-fixacao.component.html',
styleUrls: ['./modulo-fixacao.component.css']
})
export class ModuloFixacaoComponent {
value1: number;
value2: number;
result: number;
constructor() { }
sum() {
this.result = Number(this.value1) + Number(this.value2);
}
sub() {
this.result = Number(this.value1) - Number(this.value2);
}
mult() {
this.result = Number(this.value1) * Number(this.value2);
}
div() {
if (Number(this.value2) != 0) {
this.result = Number(this.value1) / Number(this.value2);
}
else{
alert('Não é possivel efetuar divisão por 0');
}
}
}
<h3>Programming a Calculator with Angular</h3>
<br><br>
Digite o primeiro valor: <input type="text"
[(ngModel)]="value1"/>
Digite o segundo valor: <input type="text"
[(ngModel)]="value2" />
<select #classe (change)="0">
<option value="soma">Soma</option>
<option value="sub">Sub</option>
<option value="mult">Multiplicação</option>
<option value="div">Divisão</option>
</select>
<!--Nao consigo achar um meio de passar os resultados ate a tela-->
Thank you very much! Would you have any tips to facilitate the studies in Angular? I’m thinking of studying TS and HTML separately, this would be useful?
– Ravel Sbrissa Okada