I'm developing an app with ionic 3, and I want to do a calculation with some fields, and show the result in another input ... For example, I need to report a Selling Price, Quantity and Discount, the result will be shown in TotalTotal.
<ion-item>
<ion-label floating><b>Preço Venda(R$)</b></ion-label>
<ion-input type="number" formControlName="pv" ></ion-input>
{{pedido.pv}}
</ion-item>
<ion-item *ngIf="!form.controls.pv.valid && (form.controls.pv.dirty || form.controls.pv.touched)" color="danger"
(ionFocus)="recebeValorTotal()">
<div [hidden]="!form.controls.pv.errors.required">
<ion-icon name="alert"> O campo é obrigatório</ion-icon>
</div>
</ion-item>
<ion-item>
<ion-label floating><b>Qtde(UN)</b></ion-label>
<ion-input type="number" formControlName="qtde" (ionFocus)="recebeValorTotal()"></ion-input>
{{pedido.qtde}}
</ion-item>
<ion-item *ngIf="!form.controls.qtde.valid && (form.controls.qtde.dirty || form.controls.qtde.touched)" color="danger">
<div [hidden]="!form.controls.qtde.errors.required">
<ion-icon name="alert"> O campo é obrigatório</ion-icon>
</div>
</ion-item>
<ion-item>
<ion-label floating><b>Descontos(%)</b></ion-label>
<ion-input type="number" formControlName="desc" (ionFocus)="recebeValorTotal()"></ion-input>
{{pedido.desc}}
</ion-item>
<ion-item *ngIf="!form.controls.desc.valid && (form.controls.desc.dirty || form.controls.desc.touched)" color="danger">
<div [hidden]="!form.controls.desc.errors.required">
<ion-icon name="alert"> O campo é obrigatório</ion-icon>
</div>
</ion-item>
</ion-list>
Total (R $)
recebeValorTotal(){
let total = (this.qtde * this.pv);
let aux = ((this.desc * total) / 100);
this.valTot = (total - aux);
}