1

I have an angularjs app. In the html page I call some REST services when the page is loading. I want to calculate the time taken in loading the page.

I found below code at Calculating Page Load Time In JavaScript:

window.onload = function () {
    var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart; 
    console.log('Page load time is '+ loadTime);
}

But it uses window.onload.

Which angularjs directive should I use to execute this logic after the page load is done.

Thanks.

3
  • Take a look to this answer: stackoverflow.com/a/18646795/5119765 Commented Apr 27, 2016 at 6:59
  • What actually you want to perform? Do you want to do something once you get data from api? Commented Apr 27, 2016 at 7:19
  • @Abhinav I wanted to log the total time taken by the browser to load the page completely. Commented Apr 27, 2016 at 14:55

1 Answer 1

4
angular.element(document).ready(function(){
//do it here
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.