my goal it to create a search box that will filter a collection either by searching all the fields, or by a specific attribute. this will be determined by a select.
it is able to search by specific attribute, as expected, using this custom filter: my html-
<tr ng-repeat="smartphone in smartphones | filter: search ">
JS-
$scope.search = function (item){
if (item[$scope.selectedSearchBy].indexOf($scope.query)!=-1) {
return true;
}
return false;
};
note that in order to search on all of the fields, i can change my ng-repeat to be filtered as following:
<tr ng-repeat="smartphone in smartphones | filter:query ">
and it will work.
However, both will not work together.
my question is:
how can i create a truly generic binded dropdown and search box. that will receive the searchable attributes and take care of the filtering appropriatly? (preferably without using ng-show or making DOM manipulations).
would love to supply more details if needed.