Skip to content

Instantly share code, notes, and snippets.

@jberndsen
Created December 7, 2015 10:56
Show Gist options
  • Save jberndsen/ecfff558fe618a43ce21 to your computer and use it in GitHub Desktop.
Save jberndsen/ecfff558fe618a43ce21 to your computer and use it in GitHub Desktop.
(function(angular) {
'use strict';
angular.module('app').filter('dutchmoney', function () {
return function(input) {
var result = roundToTwo(parseFloat(input) + 'e+2').toFixed(2).replace('.', ',');
return isNaN(result) ? "" : result;
};
function roundToTwo(num) {
return +(Math.round(num) + 'e-2');
}
});
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment