0

In the below code to search the record in the table, i added the "searchTutorial" at the filter option (filter:searchTutorila).

But if wanted to search only by the courseName and FacultyName, how the code has to be changed.

> <input id="searchCourseFaculty" type="text" ng-model="searchTutorial">
> <tr ng-repeat ="train in training | filter:searchTutorial"> <td>{{train.SessionID}}</td><td>{{train.SessionDate}}</td><td>{{train.CourseName}}</td><td>{{train.FacultyName}}</td>
> </tr>

If any know the answer, please post it.

1 Answer 1

1
 <input id="searchCourseFaculty" type="text" ng-model="query">

in controller

$scope.searchTutorial = function(train) {
            return (angular.lowercase(train.CourseName).indexOf(angular.lowercase($scope.query) || '') !== -1 ||
            angular.lowercase(train.FacultyName).indexOf(angular.lowercase($scope.query) || '') !== -1);
        };
Sign up to request clarification or add additional context in comments.

3 Comments

Just wanted to know, is there any other ways to achieve the same stuff using filters only
other way means? I have used filters only... by default angular in-built filter will search on all the attributes, if u want to filter based on few specific attributes, this is the way. If this solves ur problem, u can mark it as accepted.
How to do that, i have added pionts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.