I'm new to AngularJS, just created a simple form in order to understand. I tried multiplying 2 input values, I'm good here, but when I use same code to sum those 2 input values it is getting concatenated instead of sum.
My code:
<div ng-app ng-init="fval = 1;sval = 2">
<div>
First Value:
</div>
<div>
<input type="text" ng-model="fval" />
</div>
<br />
<div>
Second Value:
</div>
<div>
<input type="text" ng-model="sval" />
</div>
<br />
<div>
<label id="lblResult">{{fval * sval}}</label>
</div>
Here I have given hardcoded values for my inputs, initially we will get result as 6. Also when we change the inputs we will get correct result for multiplying 2 values.
I changed my code for addtion as below:
<label id="lblResult">{{fval + sval}}</label>
After running the application I got the correct value as 3, but when I change my input values I'm getting concatenated values. Like if I change my text box values, for firstTextBox = 12 & secondTextBox = 3, then I'm getting result value as '123'.
Hence, I'm landing with correct value when I run the application first time, but changing inputs on client side is concatenating.
Sorry for my English, since it is not my first language. Can anyone please help me where I'm going wrong.