Instead of reinventing the wheel, you can create a search filter expression that evaluates to true
or false
for each iteration in the enumerable collection.
The simplest way to do this is to define a function on your scope, as follows:
(app.js) angular.module('myApp', []) .controller('Ctrl', function ($scope) { $scope.users = [ ... ]; $scope.usermatch = function (user) { if (!angular.isDefined(user) || !angular.isDefined($scope.search)) { return false; } var nameMatch = false, numberMatch = false; if (angular.isDefined($scope.search.name) && $scope.search.name.length > 0) { if (angular.isDefined(user.firstName)) { nameMatch = nameMatch || user.firstName.indexOf($scope.search.name) > -1; } if (angular.isDefined(user.lastName)) { nameMatch = nameMatch || user.lastName.indexOf($scope.search.name) >...