当用户在Ionic 2上滚动时,提起我很困惑.我基本上想说,当用户向下滚动页面时,做一些事情.
任何例子都会很棒.
更新:
我在我的构造函数中有这个,所以当页面滚动时我想关闭键盘,因为它被打开而没有别的方法可以关闭.
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();
});
}
}
Run Code Online (Sandbox Code Playgroud)
但是我Cannot read property 'ionScroll' of undefined把它放在错误的地方我得到这个错误?
我的目标是
我遇到的问题是
食谱
// Loading Recipes
/////////////////////////////////////////////////////////////////////
loadDetails1(id){
this.apiAuthentication.loadDetails(id)
.then(data => {
this.api = data;
});
}
// Add to Shopping List
/////////////////////////////////////////////////////////////////////
submit(api) {
let toast = this.toastCtrl.create({
message: 'Added to shopping list',
duration: 1000
});
console.log(this.api);
this.storage.get('myData').then((api) => {
// add one igredient to the ingredientLines object
// if it's still a string use JSON.parse() on it
this.storage.set('myData', api).then(result =>{
toast.present();
console.log(api);
});
});
}
Run Code Online (Sandbox Code Playgroud)
HTML
<h1 (click)="submit(api?.ingredientLines)">Add to shopping list</h1>
<ul>
<li …Run Code Online (Sandbox Code Playgroud)