Based on the information provided in the documentation, it is possible to pass a function to the filter
method. You can see an example here.
<!DOCTYPE html>
<html>
<head>
<script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfcf3fae8f1fcefb3f7eeddacb3afb3a9">[email protected]</a>" data-semver="1.2.4" src="http://code.angularjs.org/1.2.4/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app="example" ng-controller="Ex">
<!-- When clicked, set the filter to our custom function defined in scope -->
<a href="#" ng-click="personFilter = isOver18">Older than 18</a>
<ul>
<li ng-repeat="p in people | filter:personFilter">
{{p.name}} - {{p.age}}
</li>
</ul>
</body>
</html>
Controller:
angular.module('example', [])
.controller('Ex', function($scope) {
$scope.personFilter = {};
$scope.people = [
{name: "Bob", age: 32},
{name: 'Billy', age: 12}
];
/* Returns true if the provided person is over 18 */
$scope.isOver18 = function(p) {
return p.age > 18;
}
});