How to run function in AngularJS controller on document ready?

Posted by Ramesh Singh | Updated on

Want to run function in AngularJS controller on document ready? We can use the angular.element(document).ready() method to attach callbacks for when the document is ready. We can simply attach the callback in the controller like so:

Here is JSFiddle example: http://jsfiddle.net/jgentes/stwyvq38/1/


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers