I have a table where I want to have an input box below each table header to filter its corresponding column. So I have 2 questions: 1. Between thead tag, how would use the "header" variable as a value for the enclosed ng-model? 2. Between tbody tag, what would be the best approach to specify the column name in the ng-repeat for the filter (filter:{ column_name: model_name })?
<table class="table table-striped table-bordered">
<thead>
<th ng-repeat="header in tableHeaders">{{header}}<a ng-click="sort_by(header);"></a>
<div>
<input type="text" ng-model="search" ng-change="filter()" class="form-control"/> <!-- value for ng-model should match header variable in enclosing ng-repeat -->
</div>
</th>
</thead>
<tbody>
<tr ng-repeat="data in filtered = (list | filter:{ Status: search} | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit"> <!-- "Status" should be corresponding column header -->
<td ng-repeat="header in tableHeaders">{{data[header]}}</td>
</tr>
</tbody>
</table>
tableheaders is an array declared in the controller:
$scope.tableHeaders = ['Environment', 'Server', 'Name', 'Status'];