Angular2 Currency Pipe change decimal separator

后端 未结 4 1136
后悔当初
后悔当初 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:36

    I'm too late but I found a solution.

    I'm just create a pipe to replace anything:

    import { PipeTransform, Injectable, Pipe }     from '@angular/core';
    @Pipe({
      name: 'replace'
    })
    @Injectable()
    export class ReplacePipe implements PipeTransform {
      constructor(){}
      transform(item: any, replace, replacement): any {
        if(item == null) return "";
        item = item.replace(replace, replacement);
        return item;
      }
    }
    

    I used that twice to solve your case.

    {{ 5.01999 | currency:'BRL':true | replace:'.':',' | replace:',00':',-' }}}
    

提交回复
热议问题