PipeOptional

wrNumber

Format a number, percent or price in the app locale.

Installation

Import the class. This entry point has no stylesheet.

import { Component } from '@angular/core';
import { WrNumber } from 'ngwr/pipes';

@Component({ imports: [WrNumber] })
export class MyComponent {}

Decimal

The default: grouped digits.

{{ 1234.5 | wrNumber }}  <!-- "1,234.5" -->
1,234.5 · 9,876,543.21

Percent

'percent' multiplies by 100.

{{ 0.875 | wrNumber: 'percent' }}  <!-- "87.5%" -->
87.5% · 4.1%

Currency

'currency' takes the ISO 4217 code as the next argument.

{{ 19.99 | wrNumber: 'currency' : 'USD' }}  <!-- "$19.99" -->
$19.99 · €19.99 · UZS 250,000.00

Custom options

Pass any Intl.NumberFormatOptions object.

{{ 19.9 | wrNumber: { minimumFractionDigits: 2 } }}      <!-- "19.90" -->
{{ 1234567 | wrNumber: { notation: 'compact' } }}        <!-- "1.2M"  -->
19.90 · 1.2M

Playground

$19.99

{{ 19.99 | wrNumber: 'currency' : 'USD' }}

Customize

Value
19.99
Style
Currency

API

NameDescriptionTypeDefault
wrNumberIntl.NumberFormat in LOCALE_ID. Takes a style or an options object.(value: number | string | null | undefined, styleOrOptions: WrNumberStyle | Intl.NumberFormatOptions = 'decimal', currency = 'USD') => string—

See also