Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


ngularJS function to format a number with min/max decimals
Had to make AngularJS function to format a number as a currency with a minimum 2 decimals and a maximum 7.
Angular supports this with the built in filter, but AngularJS did not.

.filter('preciseCurrency', function () { // show up to 7 digits of a currency value
return function (input) {
if (input < 0) {
return "$(" + Math.abs(input).toLocaleString(undefined, { minimumFractionDigits: 2 }) + ")";
} else if (input || input == 0) {
return '$' + input.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 7 });
}
else
return input;
}
})

Created By: amos 3/19/2019 1:51:39 PM