我想在angular指令中绑定页面滚动事件。我正在尝试以下代码段。但似乎事件不会被解雇:
angular.element($window).bind("scroll", function(e) {
console.log('page scrolled');
});
我需要帮助,如何实现这个?
答案 0 :(得分:0)
您可以为浏览器$window
注入$document
包装,而不是window.document
,而不是$document.bind('scroll', function(event) {
console.log('page scrolled');
});
(请参阅doc)并使用
const that = this
that.showDiv = true
that.$nextTick(function () {
that.getWindowWidth()
})