VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/angularjs-filter-filter/

⇱ AngularJS filter Filter - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AngularJS filter Filter

Last Updated : 1 Aug, 2022

The "filter" Filter in AngularJS is used to filter the array and object elements and return the filtered items. In other words, this filter selects a subset (a smaller array containing elements that meet the filter criteria) of an array from the original array.

Syntax:

{{arrayexpression | filter: expression : comparator : anyPropertyKey}}

Parameter Values:

  • arrayexpression: The source array on which the filter will be applied.
  • expression: It is used to select the items from the array after the filter conditions are met. It can be of String type, Function type, or Object type.
  • comparator: It is used to determine the value by comparing the expected value from the filter expression, and the actual value from the object array.
  • anyPropertyKey: It is an optional parameter having the special property that is used to match the value against the given property. It is of String type & its default value is $.

Example 1: This example describes the AngularJS filter Filter by filtering & rendering the name only having the character "e" in the name.

Output: 

👁 Image
 

Example 2: This example uses an object to filter its element. 

Output: 

👁 Image
 

Example 3: In this example, we are going to see a "strict" caparison that does not return any value unless it is a pure match. 

Output: 

👁 Image
 

Note: If you notice that the last Chinchwad in the array is not included in the list, because the last Chinchwad contains space before itself.

Reference: https://docs.angularjs.org/api/ng/filter/filter

Comment

Explore