The filter
filter filters an array and returns a new array.
We can use this filter to filter out items for display.
The filter method takes a string, object, or function that it will run to select or reject array elements.
If the first parameter passed in is:
!
to the string.To select all of the words that have the letter e in them
{{ ['XML', 'Java', 'Angular', 'Oracle', 'CSS', 'Javascript'] | filter:'e' }}
To filter on objects, we can use the object filter notation. The following line filters list of people objects with a list of their favorite language:
{{ [{ 'name': 'A', 'City': 'San Francisco', 'favorite language': 'Java' }, { 'name': 'B', 'City': 'San Francisco', 'favorite language': 'Javascript' }] | filter:{'favorite language': 'Java'} }}
To filter based on a function:
{{ ['Kava', 'Java', 'to', 'css'] | filter:isCapitalized }}
We can also pass a second parameter into the filter method.