I have to display Euro currency like this : 583 €.
But with this code:
{{ price | currency:\'EUR\':true }}
I get
I just didn't want to use 'fr' local, So :
import { PipeTransform} from '@angular/core';
import { Pipe } from '@angular/core';
import {CurrencyPipe} from '@angular/common';
@Pipe({ name: 'myCurrency' })
export class MyCurrencyPipe extends CurrencyPipe implements PipeTransform {
transform(value: any, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | string | boolean, digitsInfo?: string, locale?: string): string | null {
let result = super.transform(value, currencyCode, display, digitsInfo, locale);
if (result.charAt(0)==='₽' || result.charAt(0)==='$' ){
result = result.substr(1)+' ' +result.substr(0,1);
}else if(result.substr(0,3)==="TJS" || result.substr(0,3)==="RUB"){
result = result.substr(3) +" "+result.substr(0,3)
}
if ( Number(value) >0 ){
result = "+ "+ result
}else{
result = "- "+ result
}
return result;
}
}