mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
86 lines
1.5 KiB
TypeScript
86 lines
1.5 KiB
TypeScript
import {App} from 'ionic-angular';
|
|
|
|
|
|
@App({
|
|
templateUrl: 'main.html'
|
|
})
|
|
class E2EApp {
|
|
items = [];
|
|
|
|
constructor() {
|
|
for (var i = 0; i < 15; i++) {
|
|
this.items.push( getRandomData() );
|
|
}
|
|
}
|
|
|
|
doRefresh(refresher) {
|
|
console.info('Begin async operation');
|
|
|
|
getAsyncData().then(newData => {
|
|
for (var i = 0; i < newData.length; i++) {
|
|
this.items.unshift( newData[i] );
|
|
}
|
|
|
|
console.info('Finished receiving data, async operation complete');
|
|
refresher.endRefreshing();
|
|
});
|
|
}
|
|
|
|
doStart(refresher) {
|
|
console.info('Refresher, start');
|
|
}
|
|
|
|
doPulling(refresher) {
|
|
console.info('Pulling', refresher.progress);
|
|
}
|
|
|
|
}
|
|
|
|
function getAsyncData() {
|
|
// async return mock data
|
|
return new Promise(resolve => {
|
|
|
|
setTimeout(() => {
|
|
let data = [];
|
|
for (var i = 0; i < 3; i++) {
|
|
data.push( getRandomData() );
|
|
}
|
|
|
|
resolve(data);
|
|
}, 1000);
|
|
|
|
});
|
|
}
|
|
|
|
function getRandomData() {
|
|
let i = Math.floor( Math.random() * data.length );
|
|
return data[i];
|
|
}
|
|
|
|
const data = [
|
|
'Fast Times at Ridgemont High',
|
|
'Peggy Sue Got Married',
|
|
'Raising Arizona',
|
|
'Moonstruck',
|
|
'Fire Birds',
|
|
'Honeymoon in Vegas',
|
|
'Amos & Andrew',
|
|
'It Could Happen to You',
|
|
'Trapped in Paradise',
|
|
'Leaving Las Vegas',
|
|
'The Rock',
|
|
'Con Air',
|
|
'Face/Off',
|
|
'City of Angels',
|
|
'Gone in Sixty Seconds',
|
|
'The Family Man',
|
|
'Windtalkers',
|
|
'Matchstick Men',
|
|
'National Treasure',
|
|
'Ghost Rider',
|
|
'Grindhouse',
|
|
'Next',
|
|
'Kick-Ass',
|
|
'Drive Angry'
|
|
];
|