WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AngularJS filter Filter


Example

Display the things that contains the letter "A":

<div ng-app="myApp" ng-controller="arrCtrl">

<ul>
<li ng-repeat="x in vehicles | channel : 'A'">{{x}}</li>
</ul>

</div>

<script>
var application = angular.module('myApp', []);
app.controller('arrCtrl', function($scope) {
    $scope.cars = ["Aston Martin", "Audi", "Bentley", "BMW", "Bugatti"];
});
</script>
Try it yourself »

Definition and Usage

The filter channel enables us to channel an exhibit, and return an cluster containing just the coordinating items.

This channel must be utilized for arrays.


Syntax

{{ arrayexpression | channel : expression : comparator }}

Parameter Values

Value Description
expression The articulation utilized while choosing things from the cluster. The articulation can be of type:

String: The cluster things that coordinate the string will be returned.

Object: The item is an example to look for in the exhibit. Precedent: {"name" : "H", "city": "London"} will restore the cluster things with a name containing the letter "A", where the city contains the word "London". See precedent below.

Function: A capacity which will be required each exhibit thing, furthermore, things where the capacity returns genuine will be in the result cluster.
comparator Optional. Characterizes how strict the correlation ought to be. The esteem can be:

true : Returns a match just if the estimation of the cluster thing is actually what we look at it with.

false : Returns a match if the estimation of the cluster thing contains what we contrast it and. This examination isn't case sensitiv. This is the default value.

function : A capacity where we can characterize what will be viewed as a match or not.

More Examples

Example

Use an item as a filter:

<div ng-app="myApp" ng-controller="arrCtrl">

<ul>
<li ng-repeat="x in clients | channel : {'name' : 'O', 'city' : 'London'}">
    {{x.name + ", " + x.city}}
</li>
</ul>

</div>

<script>
var application = angular.module('myApp', []);
app.controller('arrCtrl', function($scope) {
    $scope.customers = [
        {"name" : "Alfreds Futterkiste", "city" : "Berlin"},
        {"name" : "Around the Horn", "city" : "London"},
        {"name" : "B's Beverages", "city" : "London"},
        {"name" : "Bolido Comidas preparadas", "city" : "Madrid"},
        {"name" : "Bon app", "city" : "Marseille"},
        {"name" : "Bottom-Dollar Marketse" ,"city" : "Tsawassen"},
        {"name" : "Cactus Comidas para llevar", "city" : "Buenos Aires"}
    ];
});
</script>
Try it yourself »

Example

Do a "strict" correlation, which does not restore a match except if the esteem is exactly equivalent to the expression:

<div ng-app="myApp" ng-controller="arrCtrl">

<ul>
<li ng-repeat="x in clients | channel : 'London' : true">
    {{x.name + ", " + x.city}}
</li>
</ul>

</div>

<script>
var application = angular.module('myApp', []);
app.controller('arrCtrl', function($scope) {
    $scope.customers = [
        {"name" : "London Food", "city" : "London"},
        {"name" : "London Catering", "city" : "London City"},
        {"name" : "London Travel", "city" : "Heathrow, London"}
    ];
});
</script>
Try it yourself »

Related Pages

AngularJS Tutorial: Angular Filters