I am having trouble with getting the total amount of price when a list of item is selected by the checkbox
. With this for loop, all I get is the first two dollar amount (I know it is the selectedTotal += (getAmount.amount + getAmount.amount)
; problem, but not sure how to fix it), I cannot get total price amount when there are more then three selected list item. tempData
is array var tempData = []
Help will be appreciated.
HTML
<label class="item item-input ">
<b class="input-label">Total Amount: </b>
<span style="margin-left:30%;"> ${{getTotal()}} </span>
</label>
CONTROLLER
$scope.getTotal = function () {
var selectedTotal = 0;
for (var i = 0; i < $scope.tempData.length; i++) {
if ($scope.tempData[i].checked) {
var getAmount = $scope.tempData[i];
selectedTotal += (getAmount.amount + getAmount.amount);
}
return selectedTotal;
}
}