Displaying and Formatting Data
The listed filters work on arrays only (limitTo being an exception,
it can cope with strings as well).When applied to an object other
that an array those filters have no effect and will simply return a
source object.
The array-related filters are often used with the ng-repeat directive to render
filtered results. In the following sections we are going to build a full example of a
table that can be sorted, filtered and paginated. Examples are built around SCRUM
backlog list from the sample application, and will illustrate how to combine filters
and the repeater directive.
Filtering with the "filter" filter
First we need to clarify that AngularJS has a filter named filter. The name is a bit
unfortunate since the word "filter" might refer to any filter in general (a transforming
function) or this specific filter named "filter".
The "filter" filter is a general-purpose filtering function that can be used to select
a subset of an array (or put differently exclude some elements). There are number
of parameter formats that can be supplied to this filter in order to drive element
selection process. In the simplest form we can provide a string in the case all fields
of all elements in a collection will be checked for a presence of a given substring.
As an example let's consider a product backlog list that we would like to filter based
on search criteria. Users would be presented with an input box where they could
type-in search criteria. The resulting list should have only elements where any
field of a given element contains a provided substring. The following screenshot
illustrates finished UI: