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', ]; }