Search code examples
angularpolyfills

How do I polyfill the IntersectionObserver in Angular 4 on ios safari?


I'm keen to use this technology on a mobile device but it's not supported in safari - hence why I need to polyfill it.

I'm currently doing <script src="assets/polyfills/intersection-observer.js"></script> in the head of the index.html but my app won't load after doing this.

I'm using Angular cli and have tried the polyfill file to no avail. Can someone who has successfully managed to get it working in Angular 4 on mobile help me out?

Thanks


Solution

  • as you are using angular cli you can install this via npm npm install intersection-observer and import into polyfills.ts as import 'intersection-observer'; - just tested in IE11