我正在按照这个教程操作,但不确定它是否过时。
我使用的是@angular/core": "^5.2.0"
,所以我使用的是版本ngx-infinite-scroll@0.8.3。
我添加了以下内容:
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
并在app.module.ts中导入了InfiniteScrollModule
。
在Search.component.ts
中,我将directives: [InfiniteScroll]
添加到@Component
中,但是当我浏览'ngx-infinite-scroll'的选项时,似乎已经不存在了。 我只能看到InfiniteScrollDirective
,但没有实现它。
唯一让应用程序编译的方法是删除directives: [InfiniteScroll]
,但是无限滚动功能不起作用(它只是一个普通的滚动)。
Html:
<div class="search-results"
infiniteScroll
[infiniteScrollDistance]="2"
[infiniteScrollThrottle]="50"
(scrolled)="onScroll()">
<div *ngFor="let name of ['a','a','b','e','r','t','t','e','b','e','r','t','ererer','a','a','b','e','r','t','t','e','b','e','r','t','ererer']">
<div>
{{name}}
</div>
</div>
</div>
CSS:
.search-results {
height: 100px;
overflow-y: scroll;
}
我的问题是无限滚动是如何实现的?
onScroll
函数来向集合中添加更多数据吗? - DevonScroll
事件(反之亦然)。 - Matan Arbel