1

I am trying to implement ngInfiniteScroll on my table with ng-repeat on <tbody> However, it doesn't get triggered when I reach the end of page.

<div infinite-scroll="list.getMoreItems()">
    <table md-table md-row-select>
        <thead md-head>
           <tr md-row>
                <th md-column><span>Id</span></th>
                <th md-column><span>Item</span></th>
            </tr>
        </thead>
       <tbody md-body ng-repeat="data in list.items">
           <tr md-row><td md-cell>{{data.title}}</td></tr>
           <tr md-row><td md-cell>Click here </td></tr>
       </tbody>
   </table>
</div>

My getMoreItems() does nothing more than throw an alert for now.

ngInfiniteScroll is configured correctly as it does execute getMoreItems() on page load but never after that.

Akshay Khetrapal
  • 2,130
  • 4
  • 18
  • 35

2 Answers2

1

In your HTML:

<tbody md-body ng-repeat="data in list.items | limitTo:barLimit">

And within your getMoreItems() method:

$scope.barLimit = 100;
$scope.getMoreItems = function () {
    $scope.barLimit += 50;
}

Based on this working example

Matthew Cawley
  • 2,638
  • 1
  • 6
  • 19
1

The issue was with the viewport to scroll calculation. Removing overflow-y:hidden from the container that contains ng-repeat solved the problem.

<div id="holdList" infinite-scroll="list.getMoreItems()">
    <table md-table md-row-select>
        <thead md-head>
           <tr md-row>
                <th md-column><span>Id</span></th>
                <th md-column><span>Item</span></th>
            </tr>
        </thead>
       <tbody md-body ng-repeat="data in list.items">
           <tr md-row><td md-cell>{{data.title}}</td></tr>
           <tr md-row><td md-cell>Click here </td></tr>
       </tbody>
   </table>
</div>


#holdList
{
   height: 100%;
   overflow: auto;
}
Akshay Khetrapal
  • 2,130
  • 4
  • 18
  • 35