The currency pipe

This pipe formats a number as a local currency, providing support for selecting the currency code such as USD for the US dollar or EUR for the euro and setting up how we want the currency info to be displayed. Its syntax is as follows:

number_expression | currency[:currencyCode[:display[:digitInfo[:locale]]]]

In the preceding statement, currencyCode is obviously the ISO 4217 currency code, while display is a string that

can either be code, assume the value symbol or symbol-narrow. The value symbol-narrow indicates whether to use the currency symbol (for example, $). The value symbol instructs to use the currency code (for example, USD) in the output. Similar to the decimal and percent pipes, we can format the output to provide a better integer and decimal sizing and grouping through the digitInfo value, we can also format based on locale.

In the following, example, we demonstrate all three forms:

import { Component, OnInit } from '@angular/core';

@Component({
selector: 'currency-demo',
template: `
<p>{{ 11256.569 | currency:"SEK":'symbol-narrow':'4.1-2' }}</p> <!--kr11,256.57 -->
<p>{{ 11256.569 | currency:"SEK":'symbol':'4.1-3' }}</p> <!--SEK11,256.569 -->
<p>{{ 11256.569 | currency:"SEK":'code' }}</p> <!--SEK11,256.57 -->
`
})
export class CurrencyDemoComponent {
constructor() { }
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset