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)
});
}
}
Also in JavaScript:
- redis nodejs
- react detect screen size
- javascript string first letter lowercase
- javascript program german to english translation
- angular 9 mat textbox
- meme discord.js
- enzyme at example
- Selectores de jQuery
- iterate table in jquery
- algolia remove object
- python vs javascript
- javascript function required arguments
- jquery get value of element
- console in jsfiddle site:stackoverflow.com
- NullInjectorError: R3InjectorError HttpClient
- encrypt and decrypt in nodejs
- call node.js file electron
- jquery order by specific order
- how to check chrome version in js
- try catch javascript
- javascript remove all spaces from string
- javascript codegolf round
- is null falsy javascript
- cypress memory leak