fix decimal places when switch to alternative amount

This commit is contained in:
Javier 2016-08-01 18:14:57 -03:00
parent d7b85e46e5
commit 074ca9c791
1 changed files with 8 additions and 2 deletions

View File

@ -26,6 +26,8 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
$scope.toggleAlternative = function() {
$scope.showAlternativeAmount = !$scope.showAlternativeAmount;
var decimals = $scope.showAlternativeAmount ? 2 : unitDecimals;
$scope.globalResult = evaluate(format($scope.amount)).toFixed(decimals);
};
function checkFontSize() {
@ -95,9 +97,13 @@ angular.module('copayApp.controllers').controller('inputAmountController', funct
var result = evaluate(formatedValue);
if (lodash.isNumber(result)) {
$scope.globalResult = isExpression(val) ? '= ' + result.toFixed(2) : '';
if ($scope.showAlternativeAmount)
$scope.globalResult = isExpression(val) ? '= ' + result.toFixed(2) : '';
else
$scope.globalResult = isExpression(val) ? '= ' + result.toFixed(unitDecimals) : '';
$scope.amountResult = toFiat(result).toFixed(2);
$scope.alternativeResult = fromFiat(result).toFixed(2);
$scope.alternativeResult = fromFiat(result).toFixed(unitDecimals);
}
};