I am currently working on a calculation for the total outside of an ng-repeat
, which is influenced by ng-change
within the ng-repeat
.
Here is a preview of my table layout:
<table>
<tr>
<td>Total - the total is {{tot}}</td>
</tr>
<tr ng-repeat="obj in Array">
<td>
<input ng-change="getValue(obj.Cost);" ng-model="obj.Quantity" type="number">
</td>
<td>
<span ng-model="obj.ListPrice">{{obj.ListPrice}}</span>
</td>
<td>
<input type="number" ng-value="obj.Cost = obj.Quantity * obj.ListPrice">
</td>
</tr>
</table>
I am now in the process of calculating the overall total.
var total = 0;
$scope.getValue = function(Cost){
total += parseInt(Cost);
$scope.tot = total
}
However, I'm encountering some issues with this calculation. Can you provide guidance on how to rectify this?