Skip to content

Instantly share code, notes, and snippets.

@sankarseran
Created October 3, 2018 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sankarseran/99d08a521bd012bb4f8494a9546bd358 to your computer and use it in GitHub Desktop.
Save sankarseran/99d08a521bd012bb4f8494a9546bd358 to your computer and use it in GitHub Desktop.
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