Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes an Angular app to load it's components halfway through the page?

Context:

I've been developing a portfolio page and wanted to put my knowledge of Angular to use. All was going fine on localhost but when I deployed, saw that the page would load mid-page.

A better example of what I'm referring to

Through GitHub, I saw that this was a reported problem and have tried a few suggested workarounds that haven't changed anything so I come humbly to you, oh mighty Stack Overflow, to see if anyone had either suggestions of workarounds or an explanation as to why that happens in the first place.

Thanks in advance!

like image 548
Sara Vasquez Avatar asked Dec 28 '25 22:12

Sara Vasquez


1 Answers

Please try to use window's scroll method in ngOnInit().

window.scroll(0,0);

ngAfterVIewChecked is called every time Angular has finished running change detection on a component and it's children.

So you can also try to set in ngAfterVIewChecked() method.

like image 185
Sachin Shah Avatar answered Dec 30 '25 16:12

Sachin Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!