2

I'm trying to use this currency pipe in component.ts file.But doesn't produce same results.

{{ money |currency: 'EUR': 'symbol' : '' : locale}}
this.currencyPipe.transform(money, 'EUR', '', true);
Abdul rahim
  • 41
  • 1
  • 1
  • 4

2 Answers2

9
//add currency pipe to your constructor in x.ts
private currencyPipe:CurrencyPipe
//add to your providers in app.module or to your child module if you have nested routes.

providers: [CurrencyPipe],

//use the pipe in x.ts as;
let some_money = 3000
let me_converted = this.currencyPipe.transform(some_money, 'Ksh.');
console.log(me_converted); //Ksh.3,000.00
7guyo
  • 3,047
  • 1
  • 30
  • 31
2

This worked for me.

locale: String;
digitInfo: String
this.currencyPipe.transform(money, 'EUR', 'symbol', digitInfo, locale);
Abdul rahim
  • 41
  • 1
  • 1
  • 4