If I use the following code in an Ionic app it does not work, but the exact same code works perfectly in a plain ng app. Is there a way to work around this?
import { Component, HostListener, Inject, OnInit } from "@angular/core";
import { DOCUMENT } from '@angular/platform-browser';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage implements OnInit {
constructor(public navCtrl: NavController,
@Inject(DOCUMENT) private document: Document) { }
ngOnInit() { }
@HostListener("window:scroll", [])
onWindowScroll() {
let number = this.document.body.scrollTop;
console.log('scrolling: ', number);
}
}