Created
October 3, 2018 08:10
-
-
Save sankarseran/99d08a521bd012bb4f8494a9546bd358 to your computer and use it in GitHub Desktop.
This file contains 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 } from '@angular/core'; | |
import { DecimalPipe } from '@angular/common'; | |
@Pipe({ | |
name: 'countConvert' | |
}) | |
export class ThousandPipe extends DecimalPipe { | |
transform(value: number): any { | |
if (499 > value) { | |
return super.transform((value || 0), '1.0-0'); | |
} else if (499 < value && 100000 > value){ | |
return super.transform(((value || 0) / 1000), '1.0-2') + ' K'; | |
} else if (100000 < value && 10000000 > value){ | |
return super.transform(((value || 0) / 100000), '1.0-2') + ' L'; | |
} else if (10000000 < value && 1000000000 > value){ | |
return super.transform(((value || 0) / 10000000), '1.0-2') + ' C'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment