saif
saif

Reputation: 487

Addition of angular form controls value is in html

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

output : 10+10=1010

expected result: 10+10=20

Upvotes: 0

Views: 509

Answers (2)

Pardeep Jain
Pardeep Jain

Reputation: 86800

Simply create one method and pass parameter along with and get return as number like this

 <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

Upvotes: 1

Vignesh
Vignesh

Reputation: 2384

Try the below code, convert them to numbers using parseInt

{{parseInt(itemInfoForm.controls['quantity'].value) + parseInt(selected_item.quantity)}}

Upvotes: 0

Related Questions