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

144
Visualizações
Failure with infinite scroll, Angular

I find a bug in my code which allows yes, to do infinite scrolling but it does not update the data, so the same data is displayed over and over again, I don't know how to solve it, I am using the latest version of Angular, I would appreciate it If one of them has a tip or, failing that, the solution. My scroll code is the following (I highlight that I am using the "ngx infinite scroll" dependency)

Componente¨

@HostListener('window:scroll', [])
  onWindowScroll(): void {
    const yOffSet = window.pageYOffset;
    if (
      (yOffSet ||
        this.document.documentElement.scrollTop ||
        this.document.body.scrollTop) > this.showScrollHeight
        ) {
          this.showButtonGoUp = true;
        } else if (
          this.showButtonGoUp &&
          (yOffSet ||
            this.document.documentElement.scrollTop ||
            this.document.body.scrollTop) < this.hideScrollHeight
            ) {
              this.showButtonGoUp = false;
            }
          }
          
          onScrollDown():void{
            if (this.info.next) {
              console.log(this.pageNum) 
              this.pageNum++;
              console.log(this.pageNum) //Prueba 1 scroll inifnito
              this.getDataFromService();
            }
          }
          
          
  onScrollTop(): void {
    this.document.body.scrollTop = 0; //Para navegador Safari
    this.document.documentElement.scrollTop = 0; //Para el resto de navegadores
  }

Everything is correctly imported, I don't show you the whole component to save space. This is the HTML:

<div class="row" infinite-scroll (scrolled)="onScrollDown()">
  <div class="col-xs-12 col-sm-6 col-md-3" *ngFor="let character of characters">
    <app-character [character]="character"></app-character>
  </div>
  <div
    class="col-xs-12 col-sm-12 col-md-12 mt-5 container-notFound"
    *ngIf="characters.length <= 0"
  >
    <p>No hay resultados de búsqueda...</p>
  </div>
</div>
<button [ngClass]="'no-hidden'"
*ngIf="showButtonGoUp"
clas="btn btn-dark"
(click)="onScrollTop">
  Ir al principio
</button>
about 4 years ago · Juan Pablo Isaza
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