1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Cant change Angular Materials paginator value after using viewChild signal

Discussão em 'Angular' iniciado por ocanyldz, Dezembro 14, 2024.

  1. ocanyldz

    ocanyldz Guest

    I need to change my tables paginators pageIndex and pageSize, my code works well when i use ViewChild, but i want to use signal query, when i use signal query i got this error;

    Writing to signals is not allowed in a computed or an effect by default.

    ///@ViewChild('paginator') paginator: MatPaginator; -->this works
    paginator = viewChild<MatPaginator>('paginator');

    _onPaginationChange(event: PageEvent) {
    const previousPageIndex = this.req.pageNumber - 1;
    const previousPageSize = this.req.pageSize;

    this.checkModifiedCellsAndCallback(() => {
    this.req.pageNumber = event.pageIndex + 1;
    this.req.pageSize = event.pageSize;
    this.getTableData();
    });

    // Revert paginator state if the user cancels the action
    if (this.modifiedCells.size > 0) {
    setTimeout(() => {
    paginator.pageIndex = previousPageIndex;
    paginator.pageSize = previousPageSize;
    });
    }
    }

    Continue reading...

Compartilhe esta Página