Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

angular scroll to top

scrollToTop(){
	window.scroll(0,0);
}
Comment

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)
    
}
}
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
Typescript :: session not created: This version of ChromeDriver only supports Chrome version 85 
Typescript :: electronjs remove menubar 
Typescript :: useref typescript 
Typescript :: recharts pie chart different colors 
Typescript :: typescript check if string is base64 or not path to src 
Typescript :: angular convert file to base64 
Typescript :: throw error in typescript 
Typescript :: how to clear all products woocommerce keep category 
Typescript :: pandas df filter results with list of string in column 
Typescript :: pip install -u git https://github.com/rapptz/discord.py@rewrite 
Typescript :: notificationManager has not been initialized 
Typescript :: randomNumberGeneratorInRange in js 
Typescript :: what is the blood vessel that carries oxygenand nutrients to the heart muscle tissue itslef 
Typescript :: ionic 4 set root page when logout 
Typescript :: react native image picker camera 
Typescript :: string to int typescript 
Typescript :: ngmodel giving error 
Typescript :: git remove commits from branch after push 
Typescript :: react tsx component example 
Typescript :: circle dot in latex 
Typescript :: typescript key options from array values 
Typescript :: How to do Email validation using Regular expression in Typescript 
Typescript :: iframe redirects to another page 
Typescript :: bootstrap dropdown menu not showing 
Typescript :: close mat dialog from component 
Typescript :: create an array for looping typescript 
Typescript :: typescript gitignore 
Typescript :: extends vs implements java 
Typescript :: macos fonts download for linux ubuntu 
Typescript :: extend type typescript 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =