當用戶在Ionic 2上滾動時拾取使我感到困惑。我基本上想說,當用戶向下滾動頁面時,做一些事情。OnScroll事件Ionic 2
任何例子都會很棒。
UPDATE:
我有這個在我的構造函數,所以當頁面滾動我要關閉鍵盤,因爲它保持打開,並沒有其他的方式來關閉。
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();
});
}
}
但是我得到這個錯誤Cannot read property 'ionScroll' of undefined
我把它放在錯誤的地方?
我假設你在視圖中有一個''標籤?你可能不得不在離子視圖生命週期中的事件中訂閱事件,而不是構造器。 –
devqon