javascript - Angular ngx-infinite-scroll is not working
问题描述
I am developing Angular project and using ngx-infinite-scroll for displaying a page with data from a database. As I followed the user guide for ngx-infinite-scroll, i installed it via npm and then added the module to a file, that exports all modules in array:
import {BrowserModule} from '@angular/platform-browser';
import {FormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {AppRoutingModule} from '../../app-routing.module';
import { InfiniteScrollModule } from "ngx-infinite-scroll";
export const ModulesExport= [
BrowserModule,
FormsModule,
HttpClientModule,
AppRoutingModule,
InfiniteScrollModule
];
After that, I imported that array in my app.module.ts and added it to the importing modules.
import { NgModule } from '@angular/core';
/* import all modules, services and components from package export files */
import {ProvidersExport} from './export/providers-services/export-providers';
import {ComponentsExport} from './export/components/export-components';
import {ExportComponentsObj} from './export/components/export-components-obj';
import {ModulesExport} from './export/modules/export-modules';
@NgModule({
declarations: [...ComponentsExport],
imports: [...ModulesExport],
providers: [...ProvidersExport],
bootstrap: [ExportComponentsObj.App]
})
export class AppModule { }
So after everything is added and ready to go, I created my component and included the required parameters for infinite scroll in my html component:
<div class="row center container">
<div class="journeysWrapper" style="height: 100%" infinite-scroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="300" (scroll)="loadMore()">
<app-journey-preview *ngFor="let journey of journeys" [journey]="journey" [journeyCount]="journeys.length" class="center row container"></app-journey-preview>
</div>
</div>
I am now trying to test if everything works correctly and just logging a sample string when the scrolling event is triggered:
loadMore() {
console.log('scrolled down!!');
}
Unfortunately, when I load the page, I get the following error:
So now I am stuck with this error and I cannot figure out why does it appear. Any help would be appreciated!
解决方案
函数是 Scrolled insted scroll, (scrolled)="fn()"
推荐阅读
- gnuplot - gnuplot中符号和文本之间的图例中的空格
- c# - 可以在运行时更新带有 XML 源的 DisplayNameAttribute 扩展吗?
- windows - Flutter windows桌面应用程序启动后立即关闭
- xml - 去测试 - Junit 结果
- cross-compiling - 在 Linux for Windows 上编译 Python C 扩展(交叉编译)
- npm - 使用 Netlify CLI 工具部署的 Netlify 问题
- php - curl响应是“内部服务器错误”,如何解决
- string - Powershell Base64 URL-safe 对上面的二进制哈希字符串进行编码,使其适用于 HTTP 请求
- datetime - MariaDB 在“视图”表上按日期时间字段过滤时返回空集,而 MySQL(和基本视图 sql)工作正常
- jupyter-notebook - 在 Jupyter-lab 中滚动提示音的键盘快捷键