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.
Syntax:
{{expression | filterName : parameter}}
Inbuilt filters for formatting the data are as follows.
Filter Name | Description |
---|
lowercase | Formats/ converts all character to lowercase. |
uppercase | Formats/ converts all character to uppercase. |
number | Format a number to a string. |
date | Formats data to a string based on provided criteria. |
currency | Formats a number as a currency. $ is default currency format. |
orderby | Orders the array according to the provided criteria. |