Currently, I am working on an Angular (1.3.14) directive that is meant to handle scrolling events on elements. Here's a snippet of the code:
var app = angular.module('myApp', []);
app.directive("scroll", function ($window) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
console.log(element.className); // this returns 'undefined'
element.on('scroll', function(e) {
console.log('scroll'); // unfortunately, this doesn't work
});
element.on('click', function(e) {
console.log('click'); // works fine
});
}
}
});
The issue I'm facing is that the scroll event does not seem to fire. While all other events like click are functioning properly, scrolling remains unresponsive. Even when trying to retrieve the element's class, it returns as 'undefined' despite having a class assigned to it. The HTML structure where this directive is applied looks something like this:
<body ng-app="myApp" ng-controller="myCtrl" ng-keydown="keyListener($event)">
<section class="dark content second" scroll="">
</section>
</body>
I am unsure about what could be causing these issues.