mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
50 lines
909 B
TypeScript
50 lines
909 B
TypeScript
import {App, InfiniteScroll} from 'ionic-angular';
|
|
|
|
|
|
@App({
|
|
templateUrl: 'main.html'
|
|
})
|
|
class E2EApp {
|
|
items = [];
|
|
|
|
constructor() {
|
|
for (var i = 0; i < 30; i++) {
|
|
this.items.push( this.items.length );
|
|
}
|
|
}
|
|
|
|
doInfinite(infiniteScroll: InfiniteScroll) {
|
|
console.log('Begin async operation');
|
|
|
|
getAsyncData().then(newData => {
|
|
for (var i = 0; i < newData.length; i++) {
|
|
this.items.push( this.items.length );
|
|
}
|
|
|
|
console.log('Finished receiving data, async operation complete');
|
|
infiniteScroll.endLoading();
|
|
|
|
if (this.items.length > 90) {
|
|
infiniteScroll.enable(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
function getAsyncData() {
|
|
// async return mock data
|
|
return new Promise(resolve => {
|
|
|
|
setTimeout(() => {
|
|
let data = [];
|
|
for (var i = 0; i < 30; i++) {
|
|
data.push(i);
|
|
}
|
|
|
|
resolve(data);
|
|
}, 500);
|
|
|
|
});
|
|
}
|