Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
Changing route not scrolling to the top of the screen on mobile

I tried all the answers on this post in order to take the user to the top of the screen when they hit a link and change the route:

Angular 2 Scroll to top on Route Change

And they all work when the application is on a web browser, but I cannot make any of those different and right answers work on a mobile device, including the simplest:

window.scrollTo(0, 0);

I also tried viewportScroller

this.viewportScroller.scrollToPosition([0, 0]);

This does not work either:

imports: [
    RouterModule.forRoot(routes, {
      scrollPositionRestoration: 'top', 

    })

  ],

Does this something to do with the viewport meta, am I doing something wrong or should I change something there?

  <meta name="viewport" content="width=device-width, initial-scale=1">

Thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I had a similar issue before.

This worked for me

ngOnInit(): void {
    document.body.scrollTop = 0;
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda