I'm looking for a filtering solution to filter results displayed in a table using ngRepeat. The filter should be based on user input.
Currently, I'm implementing it like this:
//HTML
<input type="search" ng-model="search">
<table>
<tr ng-repeat="person in clients | filter: searchFilter">
<td><input type="text" ng-model="person.Vorname"></td>
</tr>
</table>
The controller / Filter function:
app.controller('MyCtrl',function($scope){
$scope.searchFilter = function (obj) {
var re = new RegExp($scope.search, 'i');
return !$scope.search || re.test(obj.Vorname) || re.test(obj.Firma);
};
});
Everything is functioning correctly. However, I'm unsure if this is the best approach.
Should I consider moving my filter function to an Angular filter for better standards compliance?
If so, how can I pass the value from my input element to the filter? Passing the scope itself seems too dependent on the scope. What would be the best practice in this case?
Looking for guidance on the most effective way to handle this filtering process.