mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
b0318f8b39
PR Close #47582
2.3 KiB
2.3 KiB
Format data based on locale
Angular provides the following built-in data transformation pipes.
The data transformation pipes use the LOCALE_ID token to format data based on rules of each locale.
| Data transformation pipe | Details |
|---|---|
DatePipe |
Formats a date value. |
CurrencyPipe |
Transforms a number into a currency string. |
DecimalPipe |
Transforms a number into a decimal number string. |
PercentPipe |
Transforms a number into a percentage string. |
Use DatePipe to display the current date
To display the current date in the format for the current locale, use the following format for the DatePipe.
{{ today | date }}
Override current locale for CurrencyPipe
Add the locale parameter to the pipe to override the current value of LOCALE_ID token.
To force the currency to use American English (en-US), use the following format for the CurrencyPipe
{{ amount | currency : 'en-US' }}
NOTE:
The locale specified for the CurrencyPipe overrides the global LOCALE_ID token of your application.
What's next
@reviewed 2022-02-28