Here is working sample:
Directive template:
<thead>
<tr>
<th ng-repeat="column in ngColumns" ng-click="SortColumn(column.Name)">{{column.Text}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in ngModel | orderBy:predicate:reverse">
...
...
Directive controller:
controller: ["$scope", "$http", function ($scope, $http) {
// convert string to object
$scope.ngColumns = $scope.$eval($scope.ngColumns);
// models for sorting
$scope.predicate = $scope.ngColumns[0].Name;
$scope.reverse = false;
// sort function
$scope.SortColumn = function (columnName) {
$scope.predicate = columnName;
$scope.reverse = !$scope.reverse
}
}]
I hope it helps someone.