Skip to content

Instantly share code, notes, and snippets.

@lvl-svasseur
Last active December 28, 2015 22:09
Show Gist options
  • Save lvl-svasseur/7569192 to your computer and use it in GitHub Desktop.
Save lvl-svasseur/7569192 to your computer and use it in GitHub Desktop.
Angular.js - Time logging directive
// Post repeat directive for logging the rendering time
angular.module('siApp.services').directive('postRepeatDirective',
['$timeout', '$log', 'TimeTracker',
function($timeout, $log, TimeTracker) {
return function(scope, element, attrs) {
if (scope.$last){
$timeout(function(){
var timeFinishedLoadingList = TimeTracker.reviewListLoaded();
var ref = new Date(timeFinishedLoadingList);
var end = new Date();
$log.debug("## DOM rendering list took: " + (end - ref) + " 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