Import the modules

Import the InViewportModule for each component you want to use:

/src/app/app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { InViewportModule } from 'ng-in-viewport';

import { AppComponent } from './app.component';

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

If you want to support legacy browsers like for example IE11 you need to install and load IntersectionObserver polyfill to your src/polyfills.ts file:

$ yarn add intersection-observer
$ npm install --save intersection-observer
/src/polyfills.ts
import 'intersection-observer';

Last updated