Filters are an essential part of Angular that helps in formatting the expression value to show it to the users. We can easily add filters to services, directives, templates, or controllers. We can also create personalized filters as per requirements. These filters allow us to organize the data in such a way that only the data that meets the respective criteria are displayed. Filters are placed after the pipe symbol ( | ) while used in expressions.
A list of various types of filters used in Angular:
- currency: It is used to convert numbers to the currency format.
- filter: It is used to select a subset containing items from the given array.
- date: It is used to convert a date into a necessary format.
- lowercase: It is used to convert the given string into lowercase.
- uppercase: It is used to convert the given string into uppercase.
- orderBy: It is used to arrange an array by the given expression.
- json: It is used to format any object into a JSON string.
- number: It is used to convert a numeric value into a string.
- limitTo: It is used to restrict the limit of a given string or array to a particular number of elements or strings.