How can we add a simple search box to use in conjunction with ngTable?

app.controller('ModelPagingCtrl', function ($scope, ngTableParams, $filter, 
$http, DataService, helloWorldFromService, helloWorldFromFactory) {

   
    DataService.getModels().then(function (data) {
        console.log("GetModels Worked");
        $scope.data = data.d;

        $scope.tableParams = new ngTableParams({
            page: 1,
            count: 10,
            filter: {
                ModelNum: ''
            },
            sorting:
                                {
                                    ModelNum: 'asc'
                                }
        }, {
            total: $scope.data.length, // length of data
            getData: function ($defer, params) {
                // use build-in angular filter
                var filteredData = params.filter() ?
                                $filter('filter')($scope.data, 
params.filter()) :
                                $scope.data;

                var orderedData = params.sorting() ?
                                $filter('orderBy')(filteredData, 
params.orderBy()) :
                                $scope.data;

                params.total(orderedData.length);
                $defer.resolve(orderedData.slice((params.page() - 1) * 
params.count(), params.page() * params.count()));
            }



        }, function (error) {
            console.log('errror', error);
        });
    });



html


<table class="table" ng-table="tableParams" show-filter="true" >
            <tr ng-repeat="item in $data" >

            
            <td data-title="'ModelNum'" sortable="'ModelNum'" filter="{ 
'ModelNum': 'text' }">
                {{item.ModelNum}}                
                
                </td>

            <td><strong>Year:</strong><p>{{item.Year}}</p>
            <strong>Price:</strong><p>{{item.Price}}</p>
            <p>{{item.Features}}</p>
            </td>
            
            </tr>
            </table>


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to