mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
docs(demos): use angular http for slider api demo
This commit is contained in:
@ -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() {
|
||||||
|
Reference in New Issue
Block a user