0

There is a angular grid with scrollbar and on scroll we need to call the scroll event (lazy loading).

<div class="table-container" [ngClass]="{'loading': isLoading}" style="max-height: 400px; overflow-y: auto;"
     infinite-scroll
     [infiniteScrollDistance]="2"
     [infiniteScrollThrottle]="150"
     (scrolled)="onScroll($event)">
  <table [dataSource]="dataSource" matSort cdk-table class="nest-table">
  </table>
</div>

but onScroll event is not getting triggered during grid scrollbar scrolling. Please have a look and suggest.

7
  • scrolled is not a native event, I suppose it is provided by the infinite-scroll directive. Where does this directive come from? I have never seen this in Angular or Angular Material. Commented Jun 28, 2024 at 7:52
  • (scroll)="onScroll()" try using scroll event in angular Commented Jun 28, 2024 at 8:04
  • @JSONDerulo i am using ngx-infinite-scroll package Commented Jun 28, 2024 at 8:25
  • @kawai_weebster this is not a good advice here, as the scrolled event is only emitted when the threshold has been reached, while the native scroll event emits on every scroll. Commented Jun 28, 2024 at 8:47
  • You need to make sure that the scroll bar is on the table-container element and not some other element like the table. By applying a max-width and overflow-y, it looks like that's the case, however from the given code we can't be 100% sure. Without a minimal reproducible example it's hard to help here. Commented Jun 28, 2024 at 8:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.