Value 1 here has an amount of 10000, then I got the result in Value2 total of 8500, in Value3 I will input an a desired amount then Add it to the Value2.Ex: 1000 8500. So what happened to me is I cant add Value3 Value2 = Value4. I hope someone could help me.
https://stackblitz.com/edit/sum-ef7c94?file=src/app/app.component.ts,src/app/app.component.html
.html
<input style="width:300px" type="number" (keypress)="numberOnlyWithDecimal($event,xyz)"
[readonly]="true" [(ngModel)]="value1">
<input style="width:300px" type="number" (keypress)="numberOnlyWithDecimal($event,xyz)"
[readonly]="true" [(ngModel)]="value2" value = "{{myMath.abs(value1 * 0.15 - value1)}}">
<input style="width:300px" type="number" (keypress)="numberOnlyWithDecimal($event,xyz)"
[readonly]="true" [(ngModel)]="value3" >
<input style="width:300px" type="number" (keypress)="numberOnlyWithDecimal($event,xyz)"
[readonly]="true" [(ngModel)]="value4" value = "{{myMath.abs(value3 value2)}}">
CodePudding user response:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
value1: number = 10000;
value2: number = Math.abs(this.value1 * 0.15 - this.value1);
value3: number = 0;
value4: number = Math.abs(this.value2 this.value3);
public myMath = Math;
ngOnInit() {}
}
<div >
<div >
<input
type="number"
placeholder="FirstNumber"
[(ngModel)]="value1"
/><br />
Total<input
value="{{ myMath.abs(value1 * 0.15 - value1) }}"
type="number"
placeholder="Total"
[(ngModel)]="value2"
/><br />
<input
type="number"
placeholder="Input an Amount"
[(ngModel)]="value3"
/>
<input
type="number"
placeholder=""
[(ngModel)]="value4"
value="{{ myMath.abs(value2 value3) }}"
/>
</div>
</div>
Now you know how to add the 8500 to the Input amount ex: 1000 8500
Or check this snippet: