Saturday, July 21, 2012

Document Ready Event When Using AngularJS With JQuery

When you are making a page out of multiple partials/fragments in AngularJS, the document ready event for JQuery seems to fire before the page is fully assembled.

The correct way to do something when the page is fully loaded in AngularJS is by using the '$viewContentLoaded' event listener, by putting the following code into your controller.
$scope.$on('$viewContentLoaded', function(){
// do something
});

Reference: http://www.aleaiactaest.ch/angular-js-and-dom-readyness-for-jquery/

1 comment: