Angular 2 CurrencyPipe space between currency and number?

后端 未结 10 1127
轻奢々
轻奢々 2021-02-18 21:08

I noticed that there is a pipe called CurrencyPipe in Angular 2, which will filter some decimals from a number. This also adds the ISO currency indicator, ie \'USD\' or any othe

10条回答
  •  孤独总比滥情好
    2021-02-18 22:03

    Changes for Angular v5 and up


    The DISPLAY parameter is changed from boolean to string

    display string | boolean

    The format for the currency indicator. One of the following:

    • code: Show the code (such as USD).
    • symbol(default): Show the symbol (such as $).
    • symbol-narrow: Use the narrow symbol for locales that have two symbols for their currency. For example, the Canadian dollar CAD has the symbol CA$ and the symbol-narrow $. If the locale has no narrow symbol, uses the standard symbol for the locale.
    • String: Use the given string value instead of a code or a symbol. For example, an empty string will suppress the currency & symbol.
    • Boolean (marked deprecated in v5): true for symbol and false for code.

      Optional. Default is 'symbol'.

    Docs: https://angular.io/api/common/CurrencyPipe


    No custom pipes needed

    You can overwrite the currency & symbol with the string format.

    String: Use the given string value instead of a code or a symbol. For example, an empty string will suppress the currency & symbol.

    {{ product.price | currency:'USD ' }}
    

提交回复
热议问题