New Angular filter for correct the formatting issue of the currency value

This commit is contained in:
Gustavo Cortez 2014-06-26 16:11:40 -03:00
commit 5f99554478
2 changed files with 72 additions and 38 deletions

View file

@ -30,4 +30,28 @@ 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, fraction) {
var value = numberFilter(amount, fraction);
var sep = value.indexOf(formats.DECIMAL_SEP);
var group = value.indexOf(formats.GROUP_SEP);
if(amount >= 0) {
if (group > 0) {
return value.substring(0, sep);
}
else {
value = parseFloat(value);
if(value % 1 === 0) {
value = value.toFixed(0);
}
return value;
}
}
return 0;
};
} ]);