0

Does anyone know why this basic scroll directive doesn't work when I scroll in a template within ng-view? I know this is super vague but I can't find anything on the web. I have tried multiple variations of a scroll directive but none of them recognize scrolling within the template. I appreciate any help I can get. Thanks in advance!

I'm using this basic directive

directive("scroll", function ($window) {
    return function(scope, element, attrs) {
        angular.element($window).bind("scroll", function() {
            if (this.pageYOffset >= 100) {
                scope.boolChangeClass = true;
            } else {
                scope.boolChangeClass = false;
            }
        scope.$apply();
        });
    };
});

Here is the HTML

<ng-view><ng-view>

and a basic template for the view

<div scroll>
    <blah></blah>
</div>

I should also not that I am using the ngRoute to supply views to ng-view.

2 Answers 2

1

I found the issue. Everything in my code was correct. The problem is that I had a piece of css that was hiding my overflow-x. Once I removed that the scroll event started firing.

Sign up to request clarification or add additional context in comments.

Comments

0

in my case

<div ng-view></div>

I used to use directive example

<input type="password" class="form-control" scroll="user.password" required>

directive

app.directive("scroll", function () {
    return {
    };
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.