Angularjs: How to trigger event when scroll reaches to the bottom of the scroll bar in div?

后端 未结 5 718
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 04:23

I\'m trying to trigger an event when scroll bar reaches the end. I found this this example. Here is my code. The problem is that it doesn\'t call loadmore() at all. The values o

5条回答
  •  深忆病人
    2021-02-05 04:37

    When browser's scroll bar reached to down, we need to fire an event. Below code will work for Angular 6.

     import { HostListener } from '@angular/core';
         @HostListener('window:scroll', ['$event'])
          onScroll(): void {
            if ((window.innerHeight + window.scrollY) >= (document.documentElement.scrollHeight - 1)) {
              // Place your code here
            }
          }
    

提交回复
热议问题