NGX无限滚动不起作用

Rub*_*yen 5 infinite-scroll typescript angular angular5

我想实现无限滚动,我正在使用 ngx-infinite-scroll,但没有触发 onScroll() 函数。我已经尝试了我在其他问题上看到的所有内容,但没有成功。我想将 ngx-infinite-scroll 与角度材料表一起使用。

 <div
  infiniteScroll 
  [infiniteScrollDistance]="2" 
  [infiniteScrollThrottle]="50" 
  (scrolled)="onScroll()">
</div>


onScroll() {
   console.log("Scroll...");
}
Run Code Online (Sandbox Code Playgroud)

bha*_*tol 0

更新这是在不使用 ngx-infinite-scroll 的情况下回答问题

@HostListener('scroll', ['$event'])
scrolled() {
}
Run Code Online (Sandbox Code Playgroud)

或窗口:滚动

@HostListener('window:scroll', ['$event'])
scrolled() {
Run Code Online (Sandbox Code Playgroud)