Nicker

Nicker

  • NA
  • 5
  • 3k

filter table with multiple input with "OR" operator

Jun 8 2016 11:28 PM
Hi,
 
I have 2 input field, and I want to filter the table against the 2 input fields using OR instead of And.
 
However I'm unable to do it with the code below, the table return all field regardless what I type in the input, anyone can help me with it?
 
<script type="text/javascript">
function checking($scope) {
$scope.check = function(tableField,input) {
if (input.type == "or"){
if (tableField.name.indexOf(input.name) > -1 || input.name == null || tableField.created_by.indexOf(input.createdby) > -1 || input.createdby == null ){
return true
}
else{
return false
}
}
}
}
</script>
 
<table ng-table="table">
<tbody>
<tr ng-repeat="car in cars" ng-controller="checking" ng-show="check(car,externalFilters)">
<td data-title="'Name'">
{{car.name}}
</td>
<td data-title="'Created by'">
{{ car.created_by || 'unknown' }}
</td>
</tr>
</tbody>
</table> 
 

Answers (1)