Created
November 1, 2018 01:38
-
-
Save neilbo/79fe3dfac2340b2f51ac6a419432a1aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'thousandsComma', | |
}) | |
export class ThousandsCommaPipe implements PipeTransform { | |
/** | |
* Takes a value and makes it '1000' or 1000 to '1,000'. | |
*/ | |
transform(value: any) { | |
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment