AngularJS Currency Filter

www.ig‮.aeditfi‬com

In AngularJS, the currency filter is used to format a number as a currency string using the currency symbol defined by the application locale. The currency filter takes a number as input and returns a string formatted as currency.

Here's an example of using the currency filter in AngularJS:

<p>{{ 1234.5678 | currency }}</p>
<!-- Output: $1,234.57 -->

In this example, the number 1234.5678 is formatted as a currency string using the currency symbol and decimal separator defined by the application locale.

The currency filter can also take an optional argument to specify the currency symbol to use. For example:

<p>{{ 1234.5678 | currency:'€' }}</p>
<!-- Output: €1,234.57 -->

In this example, the currency symbol is set to the Euro symbol.

Additionally, the currency filter can also take a second optional argument to specify the number of decimal places to display. For example:

<p>{{ 1234.5678 | currency:'$':0 }}</p>
<!-- Output: $1,235 -->

In this example, the number of decimal places is set to zero, so the decimal portion of the number is rounded to the nearest whole number.

The currency filter is a useful tool in AngularJS for formatting numbers as currency strings, and it can be customized to fit the specific needs of an application.