【发布时间】:2015-11-09 00:12:58
【问题描述】:
我尝试在用户滚动到底部时提醒消息。我正在使用 angularJS,但它似乎没有工作。
app.controller('MainController',function($scope, $rootScope, $route, $http, $timeout){
// overflow auto
$(document).ready(function() {
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
});
});
有什么帮助吗?
【问题讨论】:
-
仅供参考,不建议在控制器中绑定事件。你应该为此制定一个指令。无论如何,您有控制台错误吗?
-
另外,您可以将
$window对象注入您的控制器或指令中。看看有没有帮助。
标签: jquery angularjs window scrolltop