4

I want to convert currency as per the regions like US , UK ,India ,Indonesia etc. and also want to convert in the number format as per region.

Example like in US $ 102,021.21 is written like this but in Indonesian format it will written something like this RP 102.021,21

So here both the number format is different. I use to convert currency using currency pipe but when I use number format with pipe one of them is not working.

this.results.records[i].totalAmount = new Intl.NumberFormat().format(this.results.records[i].totalAmount);

I used this to convert total amount to it's region's number format and currency pipe for convert amount as per currency value. But both are not working at same time. If I put them one by one then it will work. I want to do it at the same time.

Thanks in advance.

Pavan Andhukuri
  • 1,547
  • 3
  • 23
  • 49
Aarsh
  • 2,555
  • 1
  • 14
  • 32

1 Answers1

4

According to the following site

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

you can pass locale and currency code to NumberFormat. So this should give you the result you want.

  $scope.value=new Intl.NumberFormat('fr-fr', { style: 'currency', currency: 'EUR' }).format($scope.value);
Pavan Andhukuri
  • 1,547
  • 3
  • 23
  • 49