Search code examples
angular2-formsangular-forms

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


Solution

  • 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