Angular has a .filter() method for each Module, which means we can write our own custom filters.
The returned function gets invoked each time Angular calls the filter, which means two-way binding for our filters. The user makes a change, the filter runs again and updates as necessary. The name of our filter is how we can reference it inside Angular bindings.
This article represents high-level concepts and code sample/example of how to create a custom filter. How to Create A Custom Filter and in this example, we are using a custom filter to reverse the string and convert the reverse string in lower case.
To create a new filter, the filter needs to be registered as a new factory function with your module. In the example below, “reverse” filter is registered with “myApp” module using the “filter” factory function.
Example 1: Here we are creating a custom filter to reverse the string and convert the reverse string in lower case.
Example 2: Filter for ng-repeat, in example 2 we will create a custom filter to display all the name of all friends starts with A.