concept filter in category ionic

appears as: filters, filter, filters, The filters
Ionic in Action: Hybrid Mobile Apps with Ionic and AngularJS

This is an excerpt from Manning's book Ionic in Action: Hybrid Mobile Apps with Ionic and AngularJS.

  • Filters are ways to transform data in a template without modifying the source model stored in the scope.
  • 3.5.1. Filters: convert data to display in the view

    The note.date data binding in the template is followed by | date:'short'. This is called a filter, which will modify the display of the binding without changing the value on the scope. For example, here we have a date object, and using the Angular date filter, the display formats it to a human-readable format while retaining the original date object on the scope.

    Filters are used in expressions by adding the pipe character and then the filter. Filters can be chained together—in other words, you can add more than one filter. For example, a filter could sort an array (using the orderBy filter) and then another filter could reduce the array to 10 items (using the limitTo filter). The expression with the filters would appear like this:

    {{notes | orderBy:'title' | limitTo:10}}

    Angular has a handful of filters by default, such as a currency filter to format a number as a currency value (like $100.00 for US dollars or €34 for Euros) based on browser settings. Filters can also be used as a service, but that’s less common.