Angular 2 CurrencyPipe space between currency and number?

后端 未结 10 1125
轻奢々
轻奢々 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-18 21:44

    This isn't possible since the CurrencyPipe relies on Intl.NumberFormat and there is no options for this.

    That said you can switch to display $ instead of USD with the symbolDisplay parameter set to true:

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

    This will display: $123 which is a bit better ;-) If this doesn't suit you, you need to implement a custom pipe to format your number...

    See these links for more details:

    • https://github.com/angular/angular/blob/master/modules/angular2/src/facade/intl.ts#L70
    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

提交回复
热议问题