0.0.2 • Published 5 years ago

ngx-abbreviate-number v0.0.2

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

ngx-abbreviate-number

Angular pipe for abbreviate a number and add unit letters (K, M, B, T)

Demo

Installation

 $ npm install ngx-abbreviate-number

Usage

Import the NgxAbbreviateNumberModule in your app.module.ts:

import { NgxAbbreviateNumberModule } from 'ngx-abbreviate-number';

@NgModule({
  ...
  imports: [
    ...
    NgxAbbreviateNumberModule,
    ...
  ],
  ...
})
export class AppModule {}
In HTML template
{{ currentNumber | abbreviateNumber : decimalPlaces }}

Arguments

ParamTypeDetails
currentNumbernumberInitial value of number
decimalPlacesnumberThe number of digits to appear after the decimal point. It defaults to 0.

Examples

Initial valueConverted valuevalue of 'decimalPlaces'
10001Kdefault (0)
10000001Mdefault (0)
52585.3Kdefault (0)
745203745.2Kdefault (0)
52585.26K2
63126.312K3