Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
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 Respostas
Responde à pergunta

0

I had a similar issue before.

This worked for me

ngOnInit(): void {
    document.body.scrollTop = 0;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda