gpt4 book ai didi

javascript - ng Infinite Scroll、Bootstrap 3 和 AngularJS 的高度问题

转载 作者:太空宇宙 更新时间:2023-11-04 13:36:29 24 4
gpt4 key购买 nike

我正在实现 ng Infinite Scroll module在我的应用程序中,我遇到了几个问题。

我目前的问题是该函数将在每个滚动事件中触发。我在 module FAQ 中发现了对这个问题的提及。 ,但到目前为止包含一个 div 的解决方案 clear:both;在容器的末端没有帮助。

这是来自常见问题解答的引述:

Why is ngInfiniteScroll triggering my expression on every single scroll event?

The infiniteScroll directive uses the height of the element that it's attached to in order to determine how close to the bottom of the window it is. In some cases, the browser can report a height of 0, which causes this behavior. Usually, this is due to a container element that only contains floated children. The simplest way to fix this problem is to add a "spacer" element to the bottom of the container (something like div style='clear: both;' /div); see this StackOverflow question and its associated answers for more details.

想看一看并阐明问题吗?

这是我的函数和一个有效的 Plunker .

    var _page = 0;
$scope.releases = [];
$scope.loadDetails = function(id) {
_page++;
console.log(_page);
$http.get('http://api.discogs.com/artists/' + id + '/releases?page=' + _page + '&per_page=12').then(function(data2) {
$scope.releases = data2.releases;
});
};

最佳答案

我相信无限滚动在这里不是问题。我已经修复了您的代码中的一些问题,请参阅 plunk ,在我看来一切都很正常。

关于javascript - ng Infinite Scroll、Bootstrap 3 和 AngularJS 的高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23015570/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com