Hi, I’m trying to track a page scroll.
I’ve read about 20 threads (lot of them were using the old event listeners) but I can’t find where I’m doing wrong.
I’m using tabs template and in one tab I’ve put this code:
@ViewChild(Content)
content: Content;
...
ngAfterViewInit() {
console.log("After View Init");
console.log("CONTENT: ", this.content);
this.content.ionScroll.subscribe(($event) => {
this.scrollAmount = $event.scrollTop;
console.log("SCROLLING: ", this.scrollAmount);
});
}
When open that page it logs “After View Init” and this.content object but when I start scrolling nothing is logged.
I also tried using <ion-content (scroll)="onScroll($event)">
but without results. I think that is related with the <div class="scroll-content">
block that is generated by Ionic.
How can I make it works?