Javascript 如何在有角度的情况下保持平衡?

Javascript 如何在有角度的情况下保持平衡?,javascript,angular,Javascript,Angular,我在滚动页面时尝试获取客户端高度: @HostListener('window:scroll', ['$event']) onScrollEvent($event) { if ($event.scrollHeight - $event.scrollTop === $event.clientHeight) { console.log('scrolled to the end'); } }); 我需要检测用户是否滚动到页面末尾以获取高度: var height = $windo

我在滚动页面时尝试获取客户端高度:

@HostListener('window:scroll', ['$event']) onScrollEvent($event) {
   if ($event.scrollHeight - $event.scrollTop === $event.clientHeight) {
    console.log('scrolled to the end');
  }
});

我需要检测用户是否滚动到页面末尾以获取高度:

 var height = $window.innerHeight;

我想你可以这样做(,):


我不使用jQuery这不是使用jQuery$窗户是角窗的一部分。因此,您应该比较您的滚动高度和窗口高度。好的,那么如何替换此代码:
if($event.scrollHeight-$event.scrollTop===$event.clientHeight){console.log('scrolled to end');}
?我需要检测用户是否滚动到页面的末尾($window.scrollY+$window.innerHeight>=document.body.scrollHeight){//end of page}
document.documentElement.clientHeight
@HostListener("window:scroll") onWindowScroll() {
    let scroll = window.pageYOffset ||
                 document.documentElement.scrollTop ||
                 document.body.scrollTop || 0;

    const max = document.documentElement.scrollHeight -
                document.documentElement.clientHeight;

    if (scroll === max) {
        alert('Bottom');
    }
}