mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(slides): fixed the Http call, it is now using Angular's
references #642
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import {App, IonicApp} from 'ionic/ionic';
|
||||
|
||||
import {Http} from 'angular2/http';
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class MyApp {
|
||||
constructor(private app: IonicApp) {
|
||||
constructor(app: IonicApp, http: Http) {
|
||||
this.app = app;
|
||||
this.http = http;
|
||||
|
||||
this.extraOptions = {
|
||||
loop: true
|
||||
};
|
||||
@@ -17,14 +20,14 @@ class MyApp {
|
||||
|
||||
let baseUrl = 'https://api.flickr.com/services/rest/';
|
||||
|
||||
// TODO: update to use angular2's HTTP Service
|
||||
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, {
|
||||
method: 'jsonp'
|
||||
}).then((val) => {
|
||||
this.images = val.photos.photo.slice(0, 20);
|
||||
setTimeout(() => {
|
||||
this.slider.update();
|
||||
});
|
||||
this.http.get(baseUrl + '?method=flickr.groups.pools.getPhotos&group_id=1463451@N25&safe_search=1&api_key='
|
||||
+ FLICKR_API_KEY + '&nojsoncallback=1&format=json&tags=' + tags)
|
||||
.map(res => res.json())
|
||||
.subscribe(data => {
|
||||
this.images = data.photos.photo.slice(0, 20);
|
||||
setTimeout(() => {
|
||||
this.slider.update();
|
||||
});
|
||||
}, (err) => {
|
||||
alert('Unable to load images');
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user