Currently have my checkboxes adding and subtracting their costs from my total cost. How can I get my select to do the same? Currently its putting in a default value of 7700.00 when without the select field it is at 0.00. Also noticed my select field is breaking my checkbox function by not subtracting the number off when unchecked.
Updated Fiddle: http://jsfiddle.net/9exaarn2/6/
HTML:
<div ng-app>
<div ng-controller="showCrtl">
<input type="checkbox" name="additionalCoverage" ng-click="cost(150, $event.target.checked)">
<label>Add this coverage $150/YR</label>
<br>
<input type="checkbox" name="additionalCoverage" ng-click="cost(40, $event.target.checked)">
<label>and or this coverage $40/YR</label><br>
<select>
<option disabled selected>Select one...</option>
<option ng-selected="option(200)">add $200/yr</option>
<option ng-selected="option(500)">add $500/yr</option>
</select>
<h1 class="annualCost">TOTAL ANNUAL COST<br>OF HOME WARRANTY</h1>
<span style="color: green; font-size: 45px; line-height: 2;">{{annualCost}}</span>
<br>
</div>
</div>
JS:
function showCrtl($scope) {
$scope.dollarAmmount = 0.00;
$scope.annualCost = "$" + $scope.dollarAmmount + ".00";
$scope.option = function (amt) {
$scope.dollarAmmount = $scope.dollarAmmount + amt;
$scope.annualCost = "$" + $scope.dollarAmmount + ".00";
console.log($scope.dollarAmmount)
};
$scope.cost = function (amt, checked) {
amt *= checked ? 1 : -1;
$scope.dollarAmmount = $scope.dollarAmmount + amt;
$scope.annualCost = "$" + $scope.dollarAmmount + ".00";
console.log($scope.dollarAmmount)
};
}
EDIT: Oops had a typo in my fiddle. Issue still the same...