滚动事件未在指令内绑定 - angular.js

Scroll event not binding inside directive - angular.js

我做了一个 Plunker,我想在其中隐藏 To The Top 按钮,并在屏幕向下滚动时显示它。我无法在指令中捕获 scroll 事件。我关注了以下网址:

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

  2. Scroll event is not firing

我什至按照第二个 url

的建议将 overflow: scroll; class 添加到主 div

我在这里错过了什么

您没有滚动元素本身。 你正在滚动文档,所以它应该是这样的:

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