I am trying to add some values within an array, but instead of outputting the sum, it prints the 2 values next to each other.
My array is:
$scope.values = [ {amount: 5}, {amount: 5} ]
My function is:
$scope.total = function() { var total = 0; angular.forEach($scope.values, function(item) { total += item.amount; }) return total; }
When i call {{ amountRemaining() }}
it displays "55", instead of 10.
When i push another object to the array with a value of 6, it displays "556".
Another note to add, is that when i call {{values}}, it is placing the 5 inside "", which i think is the culprit.
"amount":"05"
How would i ensure the number is an integer?