简体   繁体   中英

document.ready and on load function in angular js?

I study in jquery that when only html load it fire document.ready function and when all images or everything load it fire onload function.Same I need to find in angular could you please tell what first function fire and when html is load and what function fire when everything is load in angularjs ?

Thanks

lets say that you have a div to which you want to attach on load function

 <div ng-controller="MainCtrl">
  <div ng-view></div>
 </div>

From MainCtrl you can listen the event

$scope.$on('$viewContentLoaded', function(){

});

You can listen in your controllers defined in routes like myController and myRouteController for $viewContentLoaded event, $viewContentLoaded is emitted every time the ngView content is reloaded and should provide similar functionality as the document.ready when routing in angularjs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM