我有这样的形式
<form>
<div class="col-lg-3 col-md-3 col-sm-12">
<mat-form-field class="example-full-width">
<input type="text" matInput placeholder="Percent" formControlName="txtTaxLinePerc" (change)="changeTotal()">
<span matSuffix>%</span>
</mat-form-field>
</div>
<div class="col-lg-3 col-md-3 col-sm-12">
<mat-form-field class="example-full-width">
<input type="text" matInput placeholder="Percent" formControlName="txtCompoundTaxPerc" (change)="changeTotal()">
<span matSuffix>%</span>
</mat-form-field>
</div>
<form>
<span>{{get added value}}</span>
这是我的ts代码
get txtTaxLinePerc() {
return this.addTaxTypeForm.controls.txtTaxLinePerc
}
get txtCompoundTaxPerc() {
return this.addTaxTypeForm.controls.txtCompoundTaxPerc
}
我想显示txtTaxLinePerc和txtCompoundTaxPerc的附加值
我怎样才能做到这一点。
我已经尝试添加
{{txtTaxLinePerc.value+txtCompoundTaxPerc.value}}
,但它并未添加它,只是连接了像20+40
这样的值,它将提供2040
最佳答案
试试这个
{{txtTaxLinePerc + txtCompoundTaxPerc}}
对组件文件的更改
get txtTaxLinePerc() {
return this.addTaxTypeForm.controls.txtTaxLinePerc.value
}
get txtCompoundTaxPerc() {
return this.addTaxTypeForm.controls.txtCompoundTaxPerc.value
}