7. What are custom filters? Write down a syntax of the same?

With AngularJS we can create our own filters. This can be done by associating the filter to our module. These types of filters are called custom filters.

Below is the code to count the number of elements in the string by using filter:

angular.module(‘myCountFilterApp’, [])
.filter(‘count’,function()
{
return(function(input)
{
var out=[];
out=input.split(‘,’);
return out.length;
})
});
In the above example, if the string is “21, 34, 45” then output after applying filter will be 3.