我如何格式化@pipe货币的角度空间?

Tut*_*ada 1 angular

我的管道当前打印:

{{ 200 | currency:'BRL':true }} = R$200.00
Run Code Online (Sandbox Code Playgroud)

我需要在200.00加元之间包含空格

{{ 200 | currency:'BRL':true }} = R$ 200.00`
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我吗?

LLa*_*Lai 5

您可以链接自定义管道以添加空间

@Pipe({
    name: 'space'
})
export class SpacePipe implements PipeTransform {
    transform(value: any, args?: any): any {
        return value.replace('R$', 'R$ ');
    }
}

{{ 200 | currency:'BRL':true | space }} // R$ 200.00
Run Code Online (Sandbox Code Playgroud)