docs(demos): fix refresher and infinite scroll demo to use the injectable in index

This commit is contained in:
Brandy Carney
2016-03-01 11:00:36 -05:00
parent 08178ecac0
commit f0e7a69a90
4 changed files with 122 additions and 124 deletions

View File

@@ -1,5 +1,65 @@
import {App, InfiniteScroll} from 'ionic-angular';
import {MockProvider} from './mock-provider';
import {Injectable} from 'angular2/core';
/**
* Mock Data Access Object
**/
@Injectable()
export class MockProvider {
getData() {
// return mock data synchronously
let data = [];
for (var i = 0; i < 20; i++) {
data.push( this._getRandomData() );
}
return data;
}
getAsyncData() {
// async receive mock data
return new Promise(resolve => {
setTimeout(() => {
resolve(this.getData());
}, 1000);
});
}
private _getRandomData() {
let i = Math.floor( Math.random() * this._data.length );
return this._data[i];
}
private _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',
];
}
@App({

View File

@@ -1,61 +0,0 @@
import {Injectable} from 'angular2/core';
/**
* Mock Data Access Object
**/
@Injectable()
export class MockProvider {
getData() {
// return mock data synchronously
let data = [];
for (var i = 0; i < 3; i++) {
data.push( this._getRandomData() );
}
return data;
}
getAsyncData() {
// async receive mock data
return new Promise(resolve => {
setTimeout(() => {
resolve(this.getData());
}, 1000);
});
}
private _getRandomData() {
let i = Math.floor( Math.random() * this._data.length );
return this._data[i];
}
private _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',
];
}

View File

@@ -1,5 +1,65 @@
import {App, Page, Refresher} from 'ionic-angular';
import {MockProvider} from './mock-provider';
import {Injectable} from 'angular2/core';
/**
* Mock Data Access Object
**/
@Injectable()
export class MockProvider {
getData() {
// return mock data synchronously
let data = [];
for (var i = 0; i < 3; i++) {
data.push( this._getRandomData() );
}
return data;
}
getAsyncData() {
// async receive mock data
return new Promise(resolve => {
setTimeout(() => {
resolve(this.getData());
}, 1000);
});
}
private _getRandomData() {
let i = Math.floor( Math.random() * this._data.length );
return this._data[i];
}
private _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',
];
}
@App({

View File

@@ -1,61 +0,0 @@
import {Injectable} from 'angular2/core';
/**
* Mock Data Access Object
**/
@Injectable()
export class MockProvider {
getData() {
// return mock data synchronously
let data = [];
for (var i = 0; i < 3; i++) {
data.push( this._getRandomData() );
}
return data;
}
getAsyncData() {
// async receive mock data
return new Promise(resolve => {
setTimeout(() => {
resolve(this.getData());
}, 1000);
});
}
private _getRandomData() {
let i = Math.floor( Math.random() * this._data.length );
return this._data[i];
}
private _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',
];
}