Update:
The problem was as suggested, you were trying to add strings which resulted in concatenation, After further reading and this great SO post shown below.
SO Answer
which says
Angular does not use JavaScript's eval() to evaluate expressions. Instead Angular's $parse service processes these expressions.
Angular expressions do not have access to global variables like window, document or location. This restriction is intentional. It prevents accidental access to the global state – a common source of subtle bugs.
So we can't use parseInt
in angular brackets, we can either move the calculation inside a javascript function and call it from angular brackets. My Solution is, since (*
) multiplication operator is doing type conversion, just multiply the variable by 1
so that you will get the same number and also convert the datatype to number
. Then the calculation will be done as expected. Please let me know if this fixes your issue. The html will be as so.
<td>{{single_style.thread*1 + single_style.stiching*1}} </td>
Plunkr Demo
I think in your scenario the variables are strings. The +
works as two ways, as an addition operator for numbers and as a concatenation operator for strings, so in your question, the first scenario, the operator is working as a concatenator and appending 3
and 5
as 35
, for your second case, I think multiply operator (*
) is doing type conversion
before performing operation thus the correct calculation takes place (15
), whereas in the first case type conversion is not taking place!
<td>{{parseInt(single_style.thread) + parseInt(single_style.stiching)}} </td>
<td>{{parseInt(single_style.thread) * parseInt(single_style.stiching)}}</td>