0

Here is my Javascript Code How Can I implement Search Filter Based On This Inputs? I'm currently new to angularjs.

var app = angular.module('myApp', ['angularUtils.directives.dirPagination']);
                    app.controller('workShiftController', function($scope, $http) {
                        $http.get("getWorkShiftArchiveJson?workshift_id="+getCookie('shiftId'))
                        .success(function (response) {$scope.workshift_archive = response;

                        });
                    });

Here is my HTML code

<div ng-app="myApp" ng-controller="workShiftController"> 
    <center><h1 style="font-size:2em;">Workshift Archive History</h1></center>
    <hr>
        <table class="table table-striped" at-table at-paginated at-list="filteredList" at-config="config">
        <thead>
            <tr>
                <th>Work Shift Name</th><th>First Name</th><th>Middle Name</th><th>Last Name</th>
                <th>Hours Per Day</th><th>Start Time</th><th>End Time</th><th>Period From</th><th>Period To</th>
            </tr>
        </thead>
        <tbody>
          <tr  dir-paginate="x in workshift_archive | itemsPerPage: 10 ">
            <td>{{x.workshift_name}}</td>
            <td>{{ x.first_Name }}</td>
            <td>{{ x.middle_Name }}</td>
            <td>{{ x.last_Name }}</td>
            <td>{{ x.hours_per_day }}</td>
            <td>{{ x.start_time }}</td>
            <td>{{ x.end_time }}</td>
            <td>{{ x.period_from }}</td>
            <td>{{ x.period_to }}</td>
          </tr>
        </tbody>  
        </table>
     <dir-pagination-controls></dir-pagination-controls>
    </div>

1 Answer 1

1

To give you full implemented filter I need to know about data attribute you have . I have implemented a sample plunker filter based on http get.you can filter by first name .

My html implementation

 <ul ng-controller="MyController as controller">
  <input type="text" placeholder='enter first name' ng-model="search.first_Name">

<table class="table table-striped" at-table at-paginated at-list="filteredList" at-config="config">
    <thead>
        <tr>
            <th>Work Shift Name</th><th>First Name</th><th>Middle Name</th><th>Last Name</th>
            <th>Hours Per Day</th><th>Start Time</th><th>End Time</th><th>Period From</th><th>Period To</th>
        </tr>
    </thead>
    <tbody>
      <tr  ng-repeat="x in controller.mydata| filter:search">
        <td>{{x.workshift_name}}</td>
        <td>{{ x.first_Name }}</td>
        <td>{{ x.middle_Name }}</td>
        <td>{{ x.last_Name }}</td>
        <td>{{ x.hours_per_day }}</td>
        <td>{{ x.start_time }}</td>
        <td>{{ x.end_time }}</td>
        <td>{{ x.period_from }}</td>
        <td>{{ x.period_to }}</td>
      </tr>
    </tbody>  
    </table>

Sign up to request clarification or add additional context in comments.

2 Comments

well I implemented as list to show the result . you can change to table view in your . I think that's not a problem.
THANKS ARYAN YOUR A HERO ^_^ I SOLVED IT NOW AWESOME

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.