Check out this HTML code snippet:
<ul ng-repeat="friend in friends | filter: { age: '2' } | orderBy: 'name' ">
<li>{{friend.name}}</li>
</ul>
Here is the $scope variable being used:
$scope.friends = [
{ name: "Peter", age: 2 },
{ name: "Pablo", age: 55 },
{ name: "Linda", age: 20 },
{ name: "Marta", age: 37 },
{ name: "Othello", age: 20 },
{ name: "Markus", age: 32 }
];
The output generated from the code is as follows:
Linda
Markus
Othello
Peter
Have questions about how the comparison works in the ng filter and how to specifically get friends with an age of 2? Look no further:
Peter