Looking for a way to get AngularJS'a ng-repeat orderBy filter to do a callback once it's done rendering...
Markup:
<div ng-controller="MyCtrl">
<table>
<thead>
<tr>
<th ng-click="sort('name')">Name:</th>
<th ng-click="sort('age')">Age:</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in items | orderBy:sortColumn:reverseSort">
<td>{{item.name}}</td>
<td>{{item.age}}</td>
</tr>
</tbody>
</table>
</div>
JS:
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.items = [{
"name": "John",
"age": 25
}, {
"name": "Amy",
"age": 75
}, {
"name": "Sarah",
"age": 12
}, {
"name": "Matt",
"age": 55
}, {
"name": "Xaviour",
"age": 2
}];
$scope.sortColumn = 'name';
$scope.reverseSort = false;
$scope.sort = function (column) {
$scope.sortColumn = column;
$scope.reverseSort = !$scope.reverseSort;
};
$scope.sortRenderFinished = function(){
console.log('Done Rendering!');
//Do something
};
}
As you can see.. I'd like to see something like $scope.sortRenderFinished() fire once the orderBy filter is done executing and changing the order of the table rows.
Any help would be MUCH appreciated! :-)