catellanir / ngx-uom

Angular 2+ unit of measure conversion library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngx-uom

The ngx-uom library provide a service and a pipe that can be used to convert a given numeric value from an Unit Of Measure (uom) to a another one (Ex from millimiters to inches)

Installation

To install this library, run:

$ npm install ngx-uom --save

Consuming your library

Once you have published your library to npm, you can import your library in any Angular application by running:

$ npm install ngx-uom

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { UomModule } from 'ngx-uom';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the UomModule as an import
    UomModule.forRoot(),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Pipe uom

uom pipe converts a given numeric value from an unit of measure to another one

Usage

{{value | uom : valueUom : desiredUom}}

Example

<!-- You can now use the uom pipe in the template  -->
<!-- in this example the value temperature is to be given in celsius degrees and we want to display as 
<!-- kelvin degrees -->
<h1>
  {{title}}
</h1>
<div>{{temperature | uom : 'c' : 'k'}}</div>

License

MIT © Rossano Catellani

About

Angular 2+ unit of measure conversion library


Languages

Language:JavaScript 69.9%Language:TypeScript 27.5%Language:HTML 2.6%