Numbers
formatUnit
Formats a finite number with a sanctioned Intl simple or compound unit.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { FormatUnitPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [FormatUnitPipe],
template: `{{ 12.5 | formatUnit: 'kilometer': {unitDisplay: 'long'}: 'fr' }}`,
})
export class ExampleComponent {
}
Template
{{ 12.5 | formatUnit: 'kilometer': {unitDisplay: 'long'}: 'fr' }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: unit, options. Locale is controlled separately.
Applied to the live output.
Live template data
readonly value = 12.5;
readonly parameter0 = "kilometer";
readonly parameter1 = {"unitDisplay":"long"} as const;
{{ value | formatUnit: parameter0: parameter1: "en-US" }}
Rendered output
12.5 kilometers