Skip to content

LimarenkoDenis/ngx-units-converter

Repository files navigation

NgxUnitsConverter

Angular module wrapper inspired by convert-units

Demo

Pls try - Demo playground

Installing

npm install --save ngx-units-converter

Usage

import {UnitsConvererModule} from 'ngx-units-converter'

(...)

@NgModule({
  (...)
  imports: [
    UnitsConvererModule
  ]
  (...)
})

Pipe

 Params
  - from: string, 
  - to: string, 
  Optionals
  - round: number
  
  <p> {{ 20 | unitsConverter: { from: 'mm', to: 'in', round: 3 } }}</p>

Service

List of avialable measures (length, mass...)

export class YourClass {
  public constructor(private _unitsConverorService: UnitsConverorService) {
    this._unitsConverorService.measures() 
  }
}

Get description by unit name

{
    unitname: string;
    measure: string;
    system: string;
    definition: {
      name: {
        singular: 'Millimeter',
        plural: 'Millimeters'
      },
      to_anchor: 1 / 1000
    };
}
export class YourClass {
  public constructor(private _unitsConverorService: UnitsConverorService) {
    this._unitsConverorService.describe('mm') 
  }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published