Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular route change scroll to top

RouterModule.forRoot(appRoutes, { scrollPositionRestoration: 'enabled' })
Comment

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)
        });
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: fetch request to GraphQL 
Javascript :: reinitialize datatable on button click 
Javascript :: htaccess for react 
Javascript :: fibonacci sequence in javascript 
Javascript :: es6 
Javascript :: js map iterate 
Javascript :: how can we redirect to third party page in angular 
Javascript :: javascript onkeyup multiple classes 
Javascript :: javascript change url without reload 
Javascript :: formdata appen array of strings 
Javascript :: how to fill false into array javascript 
Javascript :: get last part of url jquery 
Javascript :: js array into object 
Javascript :: scrollto element by id center 
Javascript :: serve a file in express 
Javascript :: float to string javascript 
Javascript :: js style remove property 
Javascript :: javasscript get the content inbetween a select tag 
Javascript :: jquery on 2 events 
Javascript :: how to differentiate latitude and longitude from same value in different textbox 
Javascript :: js after now 
Javascript :: how to focus icon of active screen react native 
Javascript :: block enter key using jquery 
Javascript :: adding a prototype on vue using nuxt 
Javascript :: moment string to date convert node js 
Javascript :: convert string array to objectid mongoose 
Javascript :: js pixelated 
Javascript :: Iterate with JavaScript While Loops 
Javascript :: js get location search parameter 
Javascript :: font awesome shopping cart icon 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =