pure angularjs scroll event listener

Viewed 6283

i'm using angularjs WITHOUT jquery, and trying to create scroll event listener.

tried this approach:

  $rootScope.$watch(function() {
    return $window.scrollY;
  }, function(n,o) {
    console.log('scroll');
  });

but it dosen't work..

I managed to achieve this goal using this technique to create resize listener:

  $rootScope.$watch(function() { // Listens to window size change
    return $window.innerWidth;
  }, function(n, o) {
    console.log('resize');
  });

is there a proper way to create pure angularjs scroll listener?

3 Answers

try using onscroll event of javascript

Related