0

I would like to have the following Australian currency format using angular.

$50 AUD

Trying to use the currency pipe but looks like there is no easy way to do it.

Any idea?

ove
  • 3,092
  • 6
  • 34
  • 51

2 Answers2

1

The currency pipe doesn't seem to support the format you want out of the box.

You should probably just make your own pipe for it. Something like:

import { Pipe } from "@angular/core";

@Pipe({
  name: "aud",
  pure: true
})
export class AudDirective {
  transform(value: number | string, args?: any): any {
    return "$" + value + " AUD";
  }
}

Here's a working Stackblitz for it (feel free to expand the Pipe code to make it more robust/modulable)

Jojofoulk
  • 2,127
  • 1
  • 7
  • 25
  • I am looking for existing angular currency pipe functionalities. This looks more like hard coding. – ove Apr 08 '21 at 06:34
  • Again, it doesn't come out of the box sadly, you can always expand their pipe like so: https://stackoverflow.com/questions/48669394/angular-5-currencypipe You can also have a look at the CurrencyPipe internal code to see how they do it, and implement your pipe extension in a way that looks similar and not hard-coded – Jojofoulk Apr 08 '21 at 06:37
0

there is an angular pipe called 'Currency Pipe' which you can use to format the value to a particular country's currency.

Please check this stackblitz for Australian Dollar

https://stackblitz.com/edit/angular-ivy-txzp1b?file=src%2Fapp%2Fapp.component.html

Codes: USA ==> USD, Canada ==> CAD, Australia ==> AUD, India ==> INR

Srikar Phani Kumar M
  • 1,069
  • 1
  • 3
  • 8