I have an ion-scroll component. I'm trying to execute some code during scrolling. In Ionic 1 this was possible using the on-scroll attribute and passing a function.
The documentation is also missing. Is there a built in way in Ionic 2 to detect scrolling, or do I have to fall back on adding my own event handlers using jQuery or window scroll event?
I found this solution from here: https://forum.ionicframework.com/t/ionic-2-rc4-addscrolllistener/73145/16?u=kamleshappster
You can use the
addScrollEventListener
method of the Scroll component, like so:Your HTML:
Your Typescript:
I found a solution here: “On-scroll” not working in
Using the
"addScrollEventListener"
inside"ngAfterViewChecked"
.