I have an app specified with ng-app="blahApp"
. Inside the app there are ten or so ng-include
s that each load a template via HTTP based on the URL, e.g. ng-include="'/url/to/template.html'"
.
How do I execute a single function after the app has loaded all partials into the DOM?
The reason I ask is because each template the gets loaded has some stuff that would otherwise (when not using Angular) rely on a single call to a jQuery plugin that initiates all the items on the page on $(document).ready();
. But now, document.ready doesn't work because the partials aren't loaded until some time after document.ready.
<!-- HTML: -->
<div id="tabs" ng-app="reportTabsApp" ng-controller="RootController">
<!-- Load a bunch of partials here with ng-include -->
</div>
<!-- my Angular code: -->
<script>
var reportTabsApp = angular.module("reportTabsApp", []);
reportTabsApp.controller('RootController', function($scope, $rootScope) {
console.log($scope); // this works
console.log($rootScope); // this works
$scope.$on("$viewContentLoaded", function() {
console.log(" -- VIEW CONTENT LOADED!!"); // This never happens.
});
$rootScope.$on("$viewContentLoaded", function() {
console.log(" -- VIEW CONTENT LOADED!!"); // This also never happens.
});
});
</script>