I'm currently facing a challenge with sorting a dynamic Angular table.
If I manually code the table headers, everything works smoothly. Fiddle: https://jsfiddle.net/xgL15jnf/
<thead>
<tr>
<td>
<a href="#" ng-click="sortType = 'id'; sortReverse = !sortReverse">id
<span ng-show="sortType == 'id' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
<span ng-show="sortType == 'id' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
</a>
</td>
<td>
<a href="#" ng-click="sortType = 'name'; sortReverse = !sortReverse">name
<span ng-show="sortType == 'name' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
<span ng-show="sortType == 'name' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
</a>
</td>
<td>
<a href="#" ng-click="sortType = 'cost'; sortReverse = !sortReverse">cost
<span ng-show="sortType == 'cost' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
<span ng-show="sortType == 'cost' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
</a>
</td>
</tr>
</thead>
However, when I try to generate the headers dynamically, the sorting doesn't function as expected. Fiddle: https://jsfiddle.net/m31d00sz/
<thead>
<tr>
<td ng-repeat="column in cols">
<a href="#" ng-click="sortType = '{{column}}'; sortReverse = !sortReverse">{{column}}
<span ng-show="sortType == '{{column}}' && !sortReverse" class="glyphicon glyphicon-arrow-down"></span>
<span ng-show="sortType == '{{column}}' && sortReverse" class="glyphicon glyphicon-arrow-up"></span>
</a>
</td>
</tr>
</thead>
The Search/Filter feature functions correctly in both of the provided Fiddles.
I believe there might be a simple solution that I am overlooking, and would greatly appreciate any assistance or guidance on this matter!