添加 angular 表单控件值在 html

Addition of angular form controls value is in html

 <pre> {{((itemInfoForm.controls['quantity'].value) + (selected_item.quantity))}}</pre>

输出:10+10=1010

预期结果:10+10=20

尝试下面的代码,使用 parseInt

将它们转换为数字
{{parseInt(itemInfoForm.controls['quantity'].value) + parseInt(selected_item.quantity)}}

只需创建一个方法并传递参数,并得到 return 作为数字,就像这样

 <pre> 
  {{changeType(itemInfoForm.controls['quantity'].value) + changeType(selected_item.quantity)}}
 </pre>

 ......//and in your controller side write function like this
 changeType(val){
    return +(val);
  }

Working Plunker