Reputation: 2857
How to trigger a div scroll event (not $document and $window) in Angularjs?
angular.element('div.myClassname').bind("scroll", function() {
});
Upvotes: 0
Views: 3316
Reputation: 136134
Yes you could do, but it should be implemented through the directive. Directive will give you the control over that DOM element, should restrict" 'C'
which will work for class
Markup
<div class="myClassname">
..Content here to scroll..
</div>
Directive
app.directive('myClassname', function(){
return {
restrict: 'C',
link: function(scope,element, attrs){
element.bind('scroll', function(){
//do code here
})
}
}
})
Upvotes: 2
Reputation: 1183
You know what you wrote there will work as long as div.myClassname
has overflow: scroll;
and its contents are bigger then its size. Though you have to use document.querySelector
to query. See fiddle Though I must agree with Pankaj Parkar there that creating a directive is much more preferable.
Upvotes: 2