ng-view无法识别angularJS滚动 [英] angularJS scrolling not recognized in ng-view

查看:94
本文介绍了ng-view无法识别angularJS滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道我在ng-view中滚动模板时为什么此基本滚动指令不起作用吗?我知道这太模糊了,但是我在网上找不到任何东西。我曾尝试过滚动指令的多种变体,但没有一个能识别模板中的滚动。感谢您能获得的任何帮助。

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!

我正在使用此基本指令

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();
        });
    };
});

这是HTML

<ng-view><ng-view>

和用于视图的基本模板

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

我也不应该使用ngRoute向ng-view提供视图。

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

推荐答案

我发现了问题。我代码中的所有内容都是正确的。问题是我有一块css隐藏了我的overflow-x。一旦删除,滚动事件就会开始触发。

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.

这篇关于ng-view无法识别angularJS滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆