DEV Community

Discussion on: How to Implement Animate on Scroll in Angular Web Apps - Using the AOS Library

 
ikbenignace profile image
Ignace Mella

I'm always getting errors like document. not found etc, probably because it tries to load the animations but document doesn't exists server side.

Thread Thread
 
olabima_ profile image
Bima This is Angular

Alright try this please:

// 1) import PLATFORM_ID from '@angular/core', eg:
import {  PLATFORM_ID } from '@angular/core';

// 2) Inject in the component constructor where you have to init the AOS, eg:

constructor( @Inject(PLATFORM_ID) private platformId: Object)

// 3) Wrap the AOS.init with this if statement, eg:

 if (isPlatformBrowser(this.platformId)) { AOS.init(); })
Enter fullscreen mode Exit fullscreen mode

Please give feedback thanks