How can run a line of jQuery once all the partials in the page loaded. No luck with $(document).ready and $(document).load is there any other ways?
app.controller('PageCtrl', function () {
$(document).ready( function() {
$(".left-nav").height( $('.content-area').height());
});
});
Any template which gets loaded in angular, first it get stored in $templateCache then it gets used. And for second time it directly gets fetched from $templateCache. Better you load all the template at the starting of your app inside app run block
In angular $ = angular.element.
Hope this would be helpful to you.
You can use controllers.
HTML:
Angular:
Explanation: By keeping a variable with the number of includes loaded you can tell if all of them were loaded.
$scope.$watch
listens to differences in the variable returned in the first function and reacts to it by calling the second. Now,$scope.$watch
will only fire during an Angular digest cycle.$timeout
calls the cycle, but it might not be needed, I didn't test the code. SincePageCtrl
must be the top-level controller of the application, $scope.includesLoaded may be available for the other controllers but, again, I'm not sure. If it does not work, use $rootScope instead.pankajparkar's answer is way better, though. Just my 2 cents for reference.