1
https://developer.yummly.com/documentation에서 데이터를 가져 오는 내 앱에 무한 스크롤을 넣으려고합니다. 최대 결과 값은 현재 50으로 설정되어 있습니다. 스크롤 지점에 도달 할 때마다 같은 양만큼 증가 시키길 원합니다.이오닉 2 : 무한 스크롤이 작동하지 않습니다.
내 API 호출
perpage: number = 50;
loadCategory(category:any, start:number=0) {
var url = "http://api.yummly.com/v1/api/recipes?_app_id=...&_app_key=...";
if (categoryCache[category.categoryId]) {
// already loaded data
return Promise.resolve(categoryCache[category.categoryId]);
}
// don't have the data yet
return new Promise(resolve => {
// We're using Angular HTTP provider to request the data,
// then on the response, it'll map the JSON data to a parsed JS object.
// Next, we process the data and resolve the promise with the new data.
var params = "";
category.apiParams.forEach(paramPair => {
params += "&" + paramPair.key + '=' + paramPair.value;
});
this.http.get(url + params + "&maxResult=" + this.perpage + "&start=" + start)
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
console.log(data);
console.log(this.http.get);
categoryCache[category.categoryId] = data.matches;
resolve(categoryCache[category.categoryId]);
});
});
}
여기에서 시작하고 누군가가 그 좋은 것입니다 도움이 될 수 있다면 내 페이지 .TS 파일은
public api: any = [];
private start:number=50;
loadRecipes(){
return new Promise(resolve => {
this.apiAuthentication.loadCategory(this.navParams.data)
.then(data => {
this.api = data;
});
})
}
doInfinite(infiniteScroll:any) {
setTimeout(() => {
// Text goes here
this.start = 100;
infiniteScroll.complete();
}, 500);
}
입니다.
안녕하세요 : 당신의 pagenation에 변화
loadRecipies
를 들어. 하지만 프런트 엔드에서는 실제로 아무것도로드되지 않습니까? – BA1995
당신은 어떤 특별한 이유에서'loadRecipies'에서 새로운 약속을 만들고 있습니까? –
또한 'this.api'를 다시 설정하지 않아도됩니다. –