Search code examples
javascriptangularjsangular-directive

Scroll event not binding inside directive - angular.js


I have made one Plunker where I want to hide To The Top button initially and the show it when the screen is scrolled down. I am not able to capture scroll event inside directive. I have followed below Urls:

  1. Scroll event is not fired inside directive - angular.js

  2. Scroll event is not firing

I have even added the overflow: scroll; class to main div, as per suggested by the second url

What am I missing here


Solution

  • you are not scrolling the element itself. you are scrolling the document, so it should be something like:

    $document.bind('scroll', ...)