O'Reilly logo

Ionic Cookbook by Hoc Phan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a custom filter

Filters are a feature of AngularJS and not specific to Ionic. The main reason you might want to use a filter is when you just need the data to be displayed in a different format in the view. You don't want to change the actual value in the controller or factory. This makes things very convenient because you don't have to decide upon a specific format within the controller code while leaving the flexibility in the view component.

Here is the list of some out-of-the-box filters (from https://docs.angularjs.org/api/ng/filter):

  • currency
  • number
  • date
  • json
  • lowercase
  • uppercase
  • limitTo
  • orderBy

In this recipe, you will learn how to add more filters using the angular-filter module as well as create a custom filter. The following is the screenshot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required