Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Currency pipe in component

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);
like image 409
Abdul rahim Avatar asked Apr 09 '26 15:04

Abdul rahim


2 Answers

//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
like image 137
7guyo Avatar answered Apr 12 '26 13:04

7guyo


This worked for me.

locale: String;
digitInfo: String
this.currencyPipe.transform(money, 'EUR', 'symbol', digitInfo, locale);
like image 29
Abdul rahim Avatar answered Apr 12 '26 11:04

Abdul rahim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!