I am currently working on implementing an infinite scrolling directive. Initially, when the page loads and I start scrolling, I can see the console log. However, after the first scroll, it stops working. It seems like it only triggers once.
Can anyone point out where I may be making a mistake?
Directive:
directives.directive('ngScrolled', function() {
return function(scope, elm, attr) {
var raw = elm[0];
elm.bind('scroll', function() {
console.log('scroll direct');
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
scope.$apply(attr.ngScrolled);
}
});
};
});
HTML:
<div class="col-md-7 col-lg-7" ng-style="resultsHolder" ng-include="'partials/resultCell.html'" ng-scrolled="loadMore()"></div>