Execute Document Ready Code on Angular Partials/Views

I’m dabbling with a rewrite of LoanGrid.net, and I’m considering using a single-page app approach with Angular JS as my foundation.  An issue I ran into when using views (aka “partials”) is that the standard jQuery ready() feature doesn’t work (or at least, is not reliable).

The quick work-around was discovered here:

function yourController($scope) {
   $scope.$on('$viewContentLoaded', YourDocReadyFunctionName);
}
That’s just a quick excerpt, and there are some caveats on how to properly execute that (no parentheses after the function name, for example).  Joel did a nice job capturing his experience, so rather than duplicate what he wrote, I encourage you to read his article about it!

Leave a Reply

Your email address will not be published.

*