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
Make your own custom currency pipe.
import { Pipe, PipeTransform } from '@angular/core';
import { CurrencyPipe } from '@angular/common';
@Pipe({ name: 'myCurrency' })
export class MyCurrencyPipe implements PipeTransform {
transform(num: any, currencyCode: string, showSymbol: boolean, digits: string): any {
let value = new CurrencyPipe(navigator.language).transform(num, currencyCode, showSymbol, digits);
let firstDigit = value.match(/\d/);
let symbol = value.slice(0, firstDigit.index);
let amount = value.slice(firstDigit.index);
return symbol + " " + amount;
}
}
and use it in HTML like
{{amount | myCurrency: currencyCode :true:'1.0-2'}}