How to get on scroll events?

后端 未结 4 1180
礼貌的吻别
礼貌的吻别 2020-12-24 10:31

I need to get scroll events from a div with overflow: scroll in my Angular 2 app.

It seems onscroll event do not works on Angular 2.

How could I achieve that

4条回答
  •  温柔的废话
    2020-12-24 11:13

    // @HostListener('scroll', ['$event']) // for scroll events of the current element
    @HostListener('window:scroll', ['$event']) // for window scroll events
    onScroll(event) {
      ...
    }
    

    or

提交回复
热议问题