docs(demos): use angular http for slider api demo

This commit is contained in:
Drew Rygh
2015-11-25 14:34:16 -06:00
parent b9d69da414
commit 7fce870418

View File

@ -1,34 +1,32 @@
import {App, IonicApp} from 'ionic/ionic'; import {App, IonicApp} from 'ionic/ionic';
import {Http} from 'angular2/http';
@App({ @App({
templateUrl: 'main.html' templateUrl: 'main.html',
}) })
class MyApp { class MyApp {
constructor(private app: IonicApp) { constructor(private app: IonicApp, http: Http) {
this.http = http;
this.extraOptions = { this.extraOptions = {
loop: true loop: true
}; };
this.images = []; this.images = [];
let tags = "amsterdam"; let tags = "amsterdam";
let FLICKR_API_KEY = '504fd7414f6275eb5b657ddbfba80a2c'; let FLICKR_API_KEY = '504fd7414f6275eb5b657ddbfba80a2c';
let baseUrl = 'https://api.flickr.com/services/rest/'; let baseUrl = 'https://api.flickr.com/services/rest/';
// TODO: update to use angular2's HTTP Service this.http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&format=json&nojsoncallback=1&tags=' + tags).subscribe(
Http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key=' + FLICKR_API_KEY + '&jsoncallback=JSON_CALLBACK&format=json&tags=' + tags, { data => {
method: 'jsonp' let val = data.json();
}).then((val) => {
this.images = val.photos.photo.slice(0, 20); this.images = val.photos.photo.slice(0, 20);
setTimeout(() => { setTimeout(() => {
this.slider.update(); this.slider.update();
}); });
}, (err) => { },
alert('Unable to load images'); err => console.log(err),
console.error(err); () => console.log('complete')
}) );
} }
onInit() { onInit() {