Click here to Skip to main content
14,733,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

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 ( > -1 || == null || tableField.created_by.indexOf(input.createdby) > -1 || input.createdby == null ){
 return true
 return false

<table ng-table="table">
 <tr ng-repeat="car in cars" ng-controller="checking" ng-show="check(car,externalFilters)">
 <td data-title="'Name'">
 <td data-title="'Created by'">
 {{ car.created_by || 'unknown' }}

What I have tried:

I have tried removing == null and input.createdby == null, and it works, however on load no data will be shown, as the script return false.
Sinisa Hajnal 9-Jun-16 4:05am
Remove == null as you said so the filtering works. Just handle the loading procedure separately. You could check for values immediately upon entering the fuction and return true if its still loading or have separate variable to check.

Why do you have both quotes and single quotes in data-attributes? You missed semi-colon after return true and return false.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900