Merge pull request #765 from cmgustavo/bug/number-filter-angularjs
Bug/angularjs-filter
This commit is contained in:
commit
cfdd7980b8
5 changed files with 157 additions and 42 deletions
|
|
@ -30,4 +30,44 @@ angular.module('copayApp.filters', [])
|
|||
|
||||
return addrs;
|
||||
};
|
||||
});
|
||||
})
|
||||
.filter('noFractionNumber',
|
||||
[ '$filter', '$locale',
|
||||
function(filter, locale) {
|
||||
var numberFilter = filter('number');
|
||||
var formats = locale.NUMBER_FORMATS;
|
||||
return function(amount, n) {
|
||||
var fractionSize = (typeof(n) != 'undefined') ? n : config.unitToSatoshi.toString().length - 1;
|
||||
var value = numberFilter(amount, fractionSize);
|
||||
var sep = value.indexOf(formats.DECIMAL_SEP);
|
||||
var group = value.indexOf(formats.GROUP_SEP);
|
||||
if(amount >= 0) {
|
||||
if (group > 0) {
|
||||
if (sep < 0) {
|
||||
return value;
|
||||
}
|
||||
var intValue = value.substring(0, sep);
|
||||
var floatValue = parseFloat(value.substring(sep));
|
||||
if (floatValue === 0) {
|
||||
floatValue = '';
|
||||
}
|
||||
else {
|
||||
if(floatValue % 1 === 0) {
|
||||
floatValue = floatValue.toFixed(0);
|
||||
}
|
||||
floatValue = floatValue.toString().substring(1);
|
||||
}
|
||||
var finalValue = intValue + floatValue;
|
||||
return finalValue;
|
||||
}
|
||||
else {
|
||||
value = parseFloat(value);
|
||||
if(value % 1 === 0) {
|
||||
value = value.toFixed(0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
} ]);
|
||||
|
|
|
|||
|
|
@ -193,9 +193,9 @@ angular.module('copayApp.services')
|
|||
var COIN = bitcore.util.COIN;
|
||||
|
||||
$rootScope.totalBalance = balanceSat * satToUnit;
|
||||
$rootScope.totalBalanceBTC = (balanceSat / COIN).toFixed(4);
|
||||
$rootScope.totalBalanceBTC = (balanceSat / COIN);
|
||||
$rootScope.availableBalance = safeBalanceSat * satToUnit;
|
||||
$rootScope.availableBalanceBTC = (safeBalanceSat / COIN).toFixed(4);
|
||||
$rootScope.availableBalanceBTC = (safeBalanceSat / COIN);
|
||||
var balanceByAddr = {};
|
||||
for (var ii in balanceByAddrSat) {
|
||||
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue