Building Custom Angular Filters
February 5, 2015 for Scotch.io
Not too long ago we took a look at some of the built-in Angular filters. The built-in filters cover many common use cases including formatting dates, currencies, limiting the number of items displayed and more. These filters are both useful and give insights into how we may improve our workflow when building Angular apps.
Today, we will build our own custom AngularJS filters. We’ll start simple and build a couple filters that manipulate numbers and strings, then we’ll build a filter that manipulate an entire data set. Finally, in our previous article where we discussed the built in AngularJS filters, Pierre-Adrien asked how we could use the built in Angular currency filter to display the currency denomination after the amount (i.e. 9.99$ instead of $9.99) as is common in some places of the world. Unfortunately, the built-in currency filter does not support this functionality, so we’ll build our own that does!