Last active
December 28, 2015 22:09
-
-
Save lvl-svasseur/7569192 to your computer and use it in GitHub Desktop.
Angular.js - Time logging directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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