Angular component library for units of measurement.
npm install ng-units!Build

m².
systemOfUnits. When importing the NgUnitsModule into your app module, the systemOfUnits provider will be registered into the root injector of your app.
typescript
@NgModule({
imports: [
BrowserModule,
NgUnitsModule.forRoot(),
], //...
})
export class AppModule { }
`
To initialize your system of units (adding predefined or custom quantities to it), pass a SystemOfUnitsConfig to forRoot(). Usually you'd like to implement an initializer for this config in a separate file.
`typescript
export function systemOfUnitsInitializer(): SystemOfUnitsConfig {
return {
quantities: [area, length, time, new Quantity(/*/), /...*/]
}
}
@NgModule({
imports: [
BrowserModule,
NgUnitsModule.forRoot(systemOfUnitsInitializer()),
], //...
})
`
If you want to import the NgUnitsModule into lazy loaded modules without creating a new system of units, use NgUnitsModule.forChild().
It's possible to provide separate systems of units on component or module level.
$3
To simply render converted values, use the ngQuantity pipe.
You can pass the quantity as a string, to select the quantity from the systemOfUnits
or you can bind to a quantity instance in your controller.
If you want to show the unit symbol, use :true.
`html
My value without label: {{value | ngQuantity:'Length'}}
My value with label: {{value | ngQuantity:'Length':true}}
My value with dynamic quantity: {{value | ngQuantity:myQuantity}}
`
$3
To use a quantity with ngModel, use the ngQuantity directive.
You can pass the quantity as a string, to select the quantity from the systemOfUnits
or you can bind to a quantity instance in your controller.
`html
`
$3
Use the ngUnitSelect attribute component, to fill a