Angular2 Currency Pipe change decimal separator

后端 未结 4 1138
后悔当初
后悔当初 2021-02-07 23:08

Hello angular friends,

I\'m working on an angular2 app (multiple actually). And I live in the Netherlands.

Currently I\'m formatting my currency with the followi

4条回答
  •  被撕碎了的回忆
    2021-02-07 23:43

    I find all of these solutions too big with too many lines of code to achieve something so small. The good thing about them is if you're using them a lot through your app. For smaller cases, I personally would use this approach:

    {{(checkout.delivery_fee | currency).replace('.',',')}}

    So I can display something like: Delivery fee: $5,50

    But, if you need to display a value greather than 1.000, you could use:

    {{(checkout.delivery_fee | currency).replace(',','x').replace('.',',').replace('x','.')}}

提交回复
热议问题