Hello I need help with loading Controller
I am using woocommerce plugin to display products on ionic home page.
I’m not able to set loading controller when the app loads up, loading the product. I can set loading to show up only with ‘setTimeout’ . I want to show loading till the page view loads completely. With setTimeout loading dismisses at the set interval. So sometimes it causes the page to show up blank till view loads completely.
here is my code
import { IonicPage, NavController, LoadingController,Platform, App } from 'ionic-angular';
import * as WC from 'woocommerce-api';
constructor(public navCtrl: NavController, public loadingCtrl: LoadingController,
private platform: Platform,
private app: App) {
this.WooCommerce = WC({
url: "http://www.j*******",
consumerKey: "ck_365490*****",
consumerSecret: "cs_b67f69******"
});
this.WooCommerce.getAsync("products").then( (data) => {
console.log(JSON.parse(data.body));
this.products = JSON.parse(data.body).products;
}, (err) => {
console.log(err)
});
let loading = this.loadingCtrl.create({
spinner: 'dots',
});
loading.present();
setTimeout(() => {
loading.dismiss();
}, 3000);
}
I want to show loading till the page view loads up completely
Thanks