angularjsangular-ui-bootstrapdata-paging

How to implement pagination in Angular when collection size is changing


I am trying to use angular-UI pagination for a table, where I am splicing the array where the page intersects the array. However I am not clear how to handle the fact that the array of objects is being added to and deleted to from within the table itself.

Also, I am sorting through a filter by the name property of an object in my ng-repeat. I expect what's is item[0] in my model array, does not correlate with the first item being displayed in the table via ng-repeat...I could be wrong.

I am just looking for advice on how to implement paging when the ng-repeat sorts the list, and the collection size is changing all the time.

Regards

I


Solution

  • Please see that demo : http://plnkr.co/edit/3nqRHUySsJZwpKQiMMTm?p=preview

    just set watch to yourCollection.length

    ie:

         $scope.$watch('yourCollection.length', function(){
    
            $scope.bigTotalItems = $scope.yourCollection.length;
    
          }
    
    )