This article will demonstrate built-in AngularJS Filters as well as how you can create your own custom Filters in AngularJS. This article begins with a brief introduction to AngularJS Filters. Afterwards, it demonstrates built-in AngularJS Filter with syntax and links to an example on Plunker Editor. Finally, the article discusses custom AngularJS Filters.
AngularJS Filters
AngularJS filters are used to modify output.Through filters, you can modify output in three ways -
- formatting of text or numbers etc.
- sorting data
- filtering data
AngularJS provides couple of built-in filters through which you can format your data. Their syntaxes and usage scenerios are as follow.
Lowercase
The Lowercase filter is used for transforming the characters of a string into lowercase. It takes a piece of string as an input and converts it into lowercase string.
Syntax
- {{ "STRING" | lowercase }}
"string"
Plunker- lowercase
Uppercase
The Uppercase filter is used for transforming the characters of a string into uppercase. It takes a piece of string as an input and converts it into uppercase string.
Syntax
Syntax
Output
Currency
The Currency filter is used to format numbers into currency.
Synatx
Example
Output
Plunker- currency
The Uppercase filter is used for transforming the characters of a string into uppercase. It takes a piece of string as an input and converts it into uppercase string.
Syntax
- {{ "string" | uppercase }}
Number
The Number filter is used for formatting numbers. It formats a number as text in case if the number is
The Number filter is used for formatting numbers. It formats a number as text in case if the number is
- null or undefined nothing will be returned
- infinite infinity symbol will be returned
- not a number an empty string will be returned
- {{number or string | number [: fractionsize(default-3)] }}
fractionsize is optional. It specifies the number of decimal places to round the number to. Its default value is 3.
Example
Example
- {{ 3.14156878 | number }} (default fraction size)
- {{ 3 | number : 2 }} (fraction size 2)
- 3.142
- 3.00
Currency
The Currency filter is used to format numbers into currency.
Synatx
- {{ number | currency [: symbol][: fractionsize ]| }}
Symbol and fraction size are optional. Their default values are taken from current locale if not specified.
Example
- {{ 49 | currency }} (default currency and fraction size)
- {{ 49 | currency:"EURO" }} ( e.g 'EURO' currency and default fraction size)
- {{ 49 | currency:"EURO" :0}} ( e.g 'EURO' currency and 0 fraction size)
- $49.00
- EURO49.00
- EURO49

Raj KumarPosted May 27, 2017, 3:41 PM
Nice explanation. Keep it up...
Thiruppathi RPosted May 26, 2017, 1:08 AM
Nice article........