0

he realizado un paginador mediante ngx-pagination - npm, el problema es que al pasar de pagina no sube arriba del todo y resulta muy incomodo.

Por favor ayuda, estoy seguro que sera alguna tontería.

HTML

<article  *ngFor="let post of posts | paginate: { itemsPerPage: 5, currentPage: p }">

<pagination-controls 
    class = "my-pagination"
    (pageChange)="p = $event"
    previousLabel="Anterior"
    nextLabel="Siguiente"
    autoHide = "true"
    >
</pagination-controls>
1
  • Al momento de ejecutar el evento del atributo pageChange puedes agregar window.scrollTo(0, 0) el 9 ene. 2020 a las 1:42

2 respuestas 2

1

Puedes hacer algo así

<pagination-controls (pageChange)="onPageChange($event)"></pagination-controls>

Y este seria el evento onPageChange

onPageChange(page: number) {
   this.currentPage = page;
   window.scrollTo(0, 0);
}

Fuente

0

<pagination-controls class="my-pagination" previousLabel="Anterior" nextLabel="Siguiente" (pageChange)="onPageChange($event)" class="text-center">

onPageChange(page: number) { this.p = page; window.scrollTo(0, 0); }

1
  • Pulsa en editar para agregar lo que pusiste en tu comentario en la respuesta. Dale formato anteponiendo 4 espacios a cada línea de código, o ponlo entre ```. Además, explica brevemente qué hace el código: lee Cómo responder.
    – padaleiana
    el 25 nov. 2021 a las 9:57

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.