1

I am using currency pipe but does not know how to set align right/left. If Currency is a USD display right result but If I have the use INR display wrong result.

html:-

<div> {{amount | currency : 'USD' : true}} </div>
<div> {{amount | currency : 'INR' : true}} </div>

ts:-

amount = 100;

Output:-

$100
₹100

₹100 Output is wrong. The right output is 100₹. Please tell us how to set it. If any package for this please tell. I have searched many so I have to get currency masking.

Harleen Kaur Arora
  • 1,949
  • 2
  • 23
  • 55

2 Answers2

1

The correct format for indian rupees is: ₹1, ₹2, ₹5, ₹10, etc.

To reproduce in this format, do the following:

HTML

 {{value | currency:'INR':true}}

app.module.ts

import { NgModule, LOCALE_ID } from '@angular/core';

...
   @NgModule({
....    
providers: [{ provide: LOCALE_ID, useValue: 'en-IN' },

Output

34566666 will be shown as ₹ 3,45,66,666.00

Notice: indian formatting for thousands!


If you don't care about thousands formatting, then you can 'hack' (I am not sure if this is correct to do, but the result is good enough):

app.module.ts

providers: [{ provide: LOCALE_ID, useValue: 'fr-IN' }

Output would be

34 566 666,00 ₹


app.module.ts

providers: [{ provide: LOCALE_ID, useValue: 'de-IN' }

Output would be

34.566.666,00 ₹


If all of this is not what you are looking for, then you should write a custom pipe.

Plunker demo

Vega
  • 27,856
  • 27
  • 95
  • 103
0

This post may help for your case

working example

can you try,i think we can't do in-built way to do it. So created custom pipe called split.

Robert
  • 3,373
  • 1
  • 18
  • 34