Window.onload In Angular
Is there any equivalent of window.onload event in Angular? I want to fade out and remove my preloader but only after all resources like images are loaded. Since $viewConteneLoaded
Solution 1:
What about:
ngAfterViewInit(){
// your code ...
}
It runs after the view is fully loaded. https://angular.io/api/core/AfterViewInit#ngAfterViewInit
Solution 2:
Try to use $window.onload
event.
Example:
angular.element($window).bind('load', function() {
//put you code
});
Solution 3:
Use angular's init() function to hide your preloader and run it at bottom of your page/controller so that all the content is finished loading before it reaches init function.
Solution 4:
You can use angular.element(document).ready();
as below
angular.element(document).ready(function () {
//do something
});
Post a Comment for "Window.onload In Angular"