I have 5 inputs
where I enter some values, but when I try to sum the total result is not displayed in the last input
.
HTML:
<label class="item item-input">
<span class="cinza input-label">Valor 1</span>
<input type="number" ng-model="var1"> </input></label>
<label class="item item-input">
<span class="cinza input-label">Valor 2</span>
<input type="number" ng-model="var2"> </input></label>
<label class="item item-input">
<span class="cinza input-label">Valor 3</span>
<input type="number" ng-model="var3"> </input></label>
<label class="item item-input">
<span class="cinza input-label">Valor 4</span>
<input type="number" ng-model="var4"> </input></label>
<label class="item item-input">
<span class="cinza input-label">Valor 5</span>
<input type="number" ng-model="var5"> </input></label>
<div ng-controller="Total">
<label class="item item-input">
<span class="cinza input-label">Total</span>
<input type="number" ng-model="total"> </input></label></input>
</div>
Controller:
.controller('Total', function ($state, $scope) {
$scope.var1 = 0;
$scope.var2 = 0;
$scope.var3 = 0;
$scope.var4 = 0;
$scope.var5 = 0;
var total = $scope.var1 + $scope.var2 + $scope.var3 + $scope.var4 + $scope.var5;
$scope.total = total;
})
How do I display full value in an input?