Hey Guys,
I am trying to improve my UI experience by adding a loading indicator while I am pulling the blogposts from WP but I just can’t get the LoadingController working
Any idea why?
this is my home.ts
import { Component } from '@angular/core';
import { PostDetail } from '../post-detail/post-detail';
import { NavController, LoadingController } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
templateUrl: 'home.html'
})
export class HomePage {
url: string = 'http://tradesetup.com.au/test/wp-json/wp/v2/posts';
items: any;
doRefresh(refresher) {
console.log('Begin async operation', refresher);
setTimeout(() => {
console.log('Async operation has ended');
refresher.complete();
}, 2000);
}
constructor(public navCtrl: NavController, private http: Http, private nav: NavController, public loadingCtrl: LoadingController) {
}
presentLoadingDefault() {
let loading = this.loadingCtrl.create({
content: 'Please wait...'
});
loading.present();
setTimeout(() => {
loading.dismiss();
}, 5000);
}
ionViewDidEnter() {
this.http.get( this.url )
.map(res => res.json())
.subscribe(data => {
// we've got back the raw data, now generate the core schedule data
// and save the data for later reference
this.items = data;
});
}
itemTapped(event, item) {
this.nav.push(PostDetail, {
item: item
});
}
}