I'm trying to figure out how to detect when a user scrolls in Ionic 2. In simple terms, I want to perform an action when the user scrolls down the page.
It would be really helpful if someone could provide some examples.
UPDATE:
In my constructor, I have this code snippet where I want to close the keyboard when the page is scrolled because it's sometimes left open without any other way to close it.
import { Component, ViewChild } from '@angular/core';
import { NavController, NavParams, Content } from 'ionic-angular';
import { Keyboard } from '@ionic-native/keyboard';
export class SearchPage {
@ViewChild(Content)
content:Content;
constructor(public keyboard: Keyboard, public formBuilder: FormBuilder, public navCtrl: NavController, public navParams: NavParams, public apiAuthentication: ApiAuthentication, private http: Http) {
this.content.ionScroll.subscribe((data)=>{
this.keyboard.close();
});
}
}
But I'm getting an error that says
Cannot read property 'ionScroll' of undefined
. Am I putting it in the wrong place?