此處的值 1 的數量為 10000,然后我在 Value2 中得到的結果總計為 8500,在 Value3 中我將輸入所需的數量,然后將其添加到 Value2。例如:1000 8500。所以發生在我身上的是我不能添加值 3 值 2 = 值 4。我希望有人能幫助我。
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)}}">
uj5u.com熱心網友回復:
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 class="container">
<div class="form-group">
<input
type="number"
class="form-control"
placeholder="FirstNumber"
[(ngModel)]="value1"
/><br />
Total<input
value="{{ myMath.abs(value1 * 0.15 - value1) }}"
type="number"
class="form-control"
placeholder="Total"
[(ngModel)]="value2"
/><br />
<input
type="number"
class="form-control"
placeholder="Input an Amount"
[(ngModel)]="value3"
/>
<input
type="number"
class="form-control"
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
或者檢查這個片段:
https://stackblitz.com/edit/sum-sqe2kv?file=src/app/app.component.ts,src/app/app.component.html,src/app/app.component.css
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/510202.html
標籤:html有角度的
上一篇:環境注入到應用程式內的服務
