myApp.controller('incomeController', ['$scope', function($scope) {
$scope.pay = 0;
$scope.hours = 0;
$scope.tax=0.19297;
$scope.total = function() {
return $scope.pay * $scope.hours;}
$scope.taxTotal = function ($scope){
return($scope.total * $scope.tax);}
$scope.afterTaxTotal = function ($scope){
return($scope.total - $scope.taxTotal);}
}]);
<div ng-app="myApp" ng-controller="incomeController">
<h2>Income Calculator</h2>
<br>
<br>
<p16>Pay Rate: </p16><input type="number" ng-model="pay">
<p15> Hours worked:</p15> <input type="number" ng-model="hours">
<br>
<br>
<br>
<p><b>Total Before Taxes:</b> {{ total() | currency : $ }}</p>
</div>
<p><b>Total Taxes :</b> {{ taxTotal() | currency : $ }}</p>
<p><b>Total After Taxes:</b> {{ afterTaxTotal() | currency : $ }}</p>
I am attempting a basic math exercise.
- Input two numbers from the user.
- Multiply the input numbers together.
- Multiply the result of step 2 by a fixed value.
- Subtract the result in step 2 from step 1.