Scroll event in AngularJS

后端 未结 3 1950
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 07:34

I have a div with a scrollbar in it. Now I want to get an event, that triggers every time, the user scrolls.

Is that possible in AngularJS, or do I have to use jQue

3条回答
  •  不思量自难忘°
    2021-01-05 08:29

    Solution for Angular 1.6:

    .directive("scroll", function () {
    return {
      link: function(scope, element, attrs) {
          element.bind("wheel", function() {
             console.log('Scrolled below header.');
          });
      }
    }
    

    })

    Use "wheel" instead of "scroll". It takes me few hours to find.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题