Cristina
Cristina

Reputation: 55

Filter by a certain column with angularjs

I have a table with two columns "Name" and "Description". I also have a dropdownlist with the name of these two columns. User must select one item from dropdownlist to know which column will be filtered and then insert a keyword in an input. I need to retrieve in table only the values filtered using that keyword applied on the column he selected. I want to do it using angularjs. Any ideas?

<select class="form-control">
                                    <option value="Name"> Name</option>
                                    <option value="Description">Description</option>
                                </select>
        Search: <input ng-model="searchWord"/>   
        <table class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Description</th>

                </tr>
            </thead>

            <tbody>
                <tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse | filter:searchWord" ng-click="SelectItem(item)" ng-class="{true:'success'}[item == selectedItem]">
                    <td>{{item.name}}</td>
                    <td>{{item.description}}</td>
                </tr>
            </tbody>
        </table>       

Upvotes: 2

Views: 1614

Answers (1)

Kavitha K Gowd
Kavitha K Gowd

Reputation: 527

Here's a plunker link http://plnkr.co/edit/SPPSf6yQRoF11mOwdYgJ?p=preview. You need to generate dynamic model and bind that to input box.

Upvotes: 1

Related Questions