I have a div with a scrollbar in it. Now I want to get an event, that triggers every time, the user scrolls.
Is that possible in AngularJS, or do I have to use jQuery for that?
Edit: I came up with following so far:
// JS
.directive('scroll', function() {
return function(scope, element, attrs){
angular.element(element).bind("scroll", function(){
console.log(1);
});
};
});
// HTML
<div class="wrapper" style="height: 1550px" scroll>
[...]
</div>
But that does not work (I don't see any logs in my Firebug-Console).
Solution for Angular 1.6:
.directive("scroll", function () {
return {
link: function(scope, element, attrs) {
element.bind("wheel", function() {
console.log('Scrolled below header.');
});
}
}
})
Use "wheel" instead of "scroll". It takes me few hours to find.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With