javascriptangularjsdom-eventsdirective

Detect scroll-event on every parent-element


I have a directive which should detect a scroll-event on every parent element. The scrollable element could be div with overflow:scroll or the browser-window itself. So this solution does not work in all cases:

angular.element($window).bind("scroll", function() { ... });

Solution

  • Okay, I found the solution. Here it is:

    angular.element(document.querySelectorAll('*')).bind("scroll", $scope.myFunction);