Skip to content

Instantly share code, notes, and snippets.

@grafikchaos
Forked from rkgarg/post-repeat-directive.js
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grafikchaos/ef12d27598ba961d7eae to your computer and use it in GitHub Desktop.
Save grafikchaos/ef12d27598ba961d7eae to your computer and use it in GitHub Desktop.
// Post repeat directive for logging the rendering time
angular.module('myApp').directive('postRepeatDirective',
['$timeout',
function($timeout) {
return function(scope) {
if (scope.$first)
window.a = new Date(); // window.a can be updated anywhere if to reset counter at some action if ng-repeat is not getting started from $first
if (scope.$last)
$timeout(function(){
console.log("## DOM rendering list took: " + (new Date() - window.a) + " ms");
});
};
}
]);
// Use in HTML:
<tr ng-repeat="item in items" post-repeat-directive></tr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment