滚动上的角负载数据[For Loop] [英] Angular Load Data on Scroll [For Loop]
本文介绍了滚动上的角负载数据[For Loop]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在显示与搜索词有关的数据.此数据可一次显示所有结果.
I am showing the data related to the search term. This data shows all the results at once.
我想做的是一次显示6个数据,然后将其余数据加载到滚动条中.
What I want to do is show 6 data once and load the remaining on a scroll.
<li *ngFor="let category of categories">
{{ category.name }}
</li>
如何滚动显示数据?
推荐答案
当滚动到达页面底部时,您可以侦听window:scroll
事件并加载数据:
You could listen to the window:scroll
events and load data when the scroll reaches the bottom of the page :
@HostListener("window:scroll", [])
onScroll(): void {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
// Load Your Data Here
}
}
这篇关于滚动上的角负载数据[For Loop]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文