This post is in continuation of my previous post regarding Filters. (Click here to go to previous post). In last post we discussed about the basics of Angular Filters and found that how easy is to use the predefined filters with examples. This post is also fourteenth post in the series of AngularJS and to see all the previous posts, click here.
In this post, we will be discussing about custom Filter, its uses and create a few custom ones. Also we’ll try to explore some more flavors of the filters. We discussed two main types of Filters in previous post, one that transforms a single item in different format. Another one that can be applied on array of items which produces another array after applying Filter .The resultant array could have same or less number of elements and contain same or transformed data. As we discussed in my earlier posts that Modules in Angular are like containers. It is a top level element and contains all the components of AngularJS. So every custom items must be registered with it. Same is true here as well. Let’s start creating a filter of first type, we already saw some Filters like uppercase, lowercase, currency etc. Now we are going to create a Filter which currently does not exist. It takes a string of numbers and convert into phone number format. Excited?