Skip to content

Instantly share code, notes, and snippets.

View happysahota's full-sized avatar

Harpreet Singh Sahota happysahota

View GitHub Profile
@timgit
timgit / megaNumber.js
Last active January 15, 2020 08:35
Large number format filter for Angular written in ES6 that rounds to the specified decimal place (defaults to 1). 1 billion => 1B, 1,490,000 => 1.5M, 999,999 => 1M
angular.module('utilsModule').filter("megaNumber", () => {
return (number, fractionSize) => {
if(number === null) return null;
if(number === 0) return "0";
if(!fractionSize || fractionSize < 0)
fractionSize = 1;
var abs = Math.abs(number);