LoadingController not working

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 :frowning:

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
		});
	}



}

I don’t see where you’re calling presentLoadingDefault.

1 Like

I am pretty new to this, where do I have to call it?

Cheers

If this is your actual code, it’s bad. You should never have arbitrary timeout numbers. If you’ve oversimplified things for posting purposes, you’re the only one who can tell us where you’ve called presentLoadingDefault().