ZoneAwareError when importing InfiniteScrollModule

时间:2017-10-12 09:38:09

标签: angular

When I import the InfiniteScrollModule from 'angular2-infinite-scroll' to my module a ZoneAwareError shown

enter image description here

1 个答案:

答案 0 :(得分:0)

你如何导入它?您是否正确遵循安装说明?

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { InfiniteScrollModule } from 'angular2-infinite-scroll';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app';

@NgModule({
  imports:[ BrowserModule, InfiniteScrollModule ],
  declarations: [ AppComponent, ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

platformBrowserDynamic().bootstrapModule(AppModule);

然后在您的组件(之前模块的一部分)模板中添加

<div class="search-results"
            infinite-scroll
            [infiniteScrollDistance]="2"
            [infiniteScrollThrottle]="300"
            (scrolled)="thisIsYourFunction()">
        </div>