Filters in AngularJS

Filters play an important role in formatting of text, date, and currency types. They modifies the data before showing in the view. Always remember filters are case-sensitive. Filters are used in AngularJS for performing the following tasks:
  • Format
  • Sort
  • Filter the data
Filters can be used with a binding expression or a directive.
To apply filter pipe (|) character is used.

{{expression | filterName : parameter}}

Inbuilt filters for formatting the data are as follows.

Filter NameDescription
lowercaseFormats/ converts all character to lowercase.
uppercaseFormats/ converts all character to uppercase.
numberFormat a number to a string.
dateFormats data to a string based on provided criteria.
currencyFormats a number as a currency. $ is default currency format.
orderbyOrders the array according to the provided criteria.