"angular scroll to top" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "angular scroll to top" answered properly. Developers are finding an appropriate answer about angular scroll to top related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like angular scroll to top. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on angular scroll to top.
angular scroll to top
scrollToTop(){
window.scroll(0,0);
}
scroll to top angular
//inside the app.component.html add (activate):
<router-outlet (activate)="onActivate($event)"></router-outlet>
//inside app.component.ts, add inside the class of the component:
export class AppComponent {
onActivate(event) {
window.scroll(0,0);
//or document.body.scrollTop = 0;
//or document.querySelector('body').scrollTo(0,0)
}
}
Source: stackoverflow.com
angular route change scroll to top
RouterModule.forRoot(appRoutes, { scrollPositionRestoration: 'enabled' })
Source: stackoverflow.com
scroll to top when routing angular
import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
@Component({
selector: 'my-app',
template: '<ng-content></ng-content>',
})
export class MyAppComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit() {
this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) {
return;
}
window.scrollTo(0, 0)
});
}
}
Source: stackoverflow.com
All those coders who are working on the TypeScript based application and are stuck on angular scroll to top can get a collection of related answers to their query. Programmers need to enter their query on angular scroll to top related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about angular scroll to top for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of angular scroll to top while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "angular scroll to top". Visit this developer's friendly online web community, CodeProZone, and get your queries like angular scroll to top resolved professionally and stay updated to the latest TypeScript updates.