Reputation: 721
I try to create directive that will simplify HTML. Now html Look like:
<tr>
<th class="span3" ng-click="setSorting('status')" ng-class="columnClass('status')">
title1
<div class="sorted-image">
<i ng-class="iconClass('status')"></i>
</div>
</th>
<th class="span4" ng-click="setSorting('sensorIdOrder')" ng-class="columnClass('sensorIdOrder')">
title2
<div class="sorted-image">
<i ng-class="iconClass('sensorIdOrder')"></i>
</div>
</th>
<th class="span3">
title3
</th>
</tr>
Where setSorting is function for sorting and set value that use in ng-repeat:
<tr ng-repeat="s in getData()| orderBy : sorting.field : !sorting.asc">
I want create thsort directive, that contain all function(setSorting, columnClass, iconClass) and use only one argument argument
<tr>
<thsort class="span3" sort-field = "status")">
title1
</thsort>
<thsort class="span4" sort-field = "sensorIdOrder">
title2
</thsort>
<th class="span3">
title3
</th>
</tr>
also all argument (Like argument) after compile applied to
Upvotes: 0
Views: 79
Reputation: 399
It's unnecessary try to create the sort directive. You can use ng-Grid directive,there support sort,custom theme and many usefull function.
Upvotes: 1