angular route change scroll to top
RouterModule.forRoot(appRoutes, { scrollPositionRestoration: 'enabled' })
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)
});
}
}
Also in JavaScript:
- SyntaxError: Unexpected end of JSON input while parsing near '...version":"2.0.6","devD' cli
- how to count specific letters in string js
- jquery alert
- get site url javascript
- less Than Or Equal To Zero javascript
- adonis attach
- mongodb replace document
- react native search bar
- discord.js send message to specific channel
- textinput onpress react native
- javascript read query parameters
- update node two versions mac
- localecompare javascript
- check if two rectangles overlap javascript canvas
- extended class call method from super in javascript
- JavaScript that executes after page load
- toggle one class add and one class remove same time and after click remove class add and add class remove jquery
- javascript get all elements of an id
- add property with value in js
- vuejs pass data to router-view
- js hoisting
- js ternary if else
- queryselector function in javascript
- set time slots with date in javascript