How to handle window scroll event in Angular 4?

后端 未结 5 1352
暗喜
暗喜 2020-11-29 20:45

I can\'t seem to be able to capture the Window scroll event. On several sites I found code similar to this:

@HostListener(\"window:scroll\", [])
onWindowScro         


        
5条回答
  •  庸人自扰
    2020-11-29 20:59

    Just in case I was looking to capture the wheel action over an element that had no way to scroll since it didn't have a scroll bar ...

    So, what I needed was this:

    @HostListener('mousewheel', ['$event']) 
    onMousewheel(event) {
         console.log(event)
    }
    

提交回复
热议问题