简体   繁体   English

在 Angular 中更改输入时更改变量

[英]change variable when inputs changed in Angular

When numbers are entered in the price(Fiyat) fields in the picture, I want the place that says 0 TL to change.当在图片中的价格(Fiyat)字段中输入数字时,我希望更改 0 TL 的地方。 The place that says 0 TL should be the sum of the numbers step by step.说0 TL的地方应该是一步一步的数字之和。 How can i do that?我怎样才能做到这一点?

<td><input (keypress)="keyPressNumbersWithDecimal($event)" type="text" id="price_{{i}}" name="price"/></td>

<td colspan="3" style="color: #f87575; text-align: right; ">{{totalPrice}} TL</td>

Note: number of inputs is dynamic注意:输入的数量是动态的

在此处输入图像描述

Instead of代替

<input (keypress)="keyPressNumbersWithDecimal($event)" type="text" id="price_{{i}}" name="price"/>

Try尝试

<input [(ngModel)]="totalPrice" type="text" id="price_{{i}}" name="price"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM