ngx-bootstrap
ngx-bootstrap copied to clipboard
One way binding for current page
I'm trying to update currentPage using store management, but it ends up with Cannot assign to read only property 'currentPage' of object '[object Object]'
.
<ng-container *ngIf="pagination$ | async as paginate">
<pagination
[(ngModel)]="paginate.currentPage"
[boundaryLinks]="true"
[itemsPerPage]="paginate.perPageRecords"
[maxSize]="paginate.maxPaginationSize"
[rotate]="true"
[totalItems]="paginate.totalRecords"
(pageChanged)="pageChanged($event)"></pagination>
</ng-container>
If I remove [(ngModel)]="paginate.currentPage"
this works well if start with first page, but won't work in condition if I jump to intermediate page eg ?page=12
.
Any work around for this?
Any updates?
You are using 2 way binding on ngrx value which is readonly and can only be changed through the state update. In your case you should change it to
<ng-container *ngIf="pagination$ | async as paginate">
<pagination
[ngModel]="paginate.currentPage"
[boundaryLinks]="true"
[itemsPerPage]="paginate.perPageRecords"
[maxSize]="paginate.maxPaginationSize"
[rotate]="true"
[totalItems]="paginate.totalRecords"
(pageChanged)="pageChanged($event)"></pagination>
</ng-container>