I've been working on a project that involves displaying products from a WooCommerce store using the ionic sidebar template.
Issue: The content on my HomePage isn't showing up initially. It only becomes visible when I click the menu toggle button, which seems to indicate a caching or loading problem.
home.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-grid>
<ion-row *ngFor="let product of products">
<ion-card>
<ion-card-header>
Name: {{product.name}}
</ion-card-header>
<ion-card-content>
<img [src]="product.images[0].src">
</ion-card-content>
</ion-card>
</ion-row>
</ion-grid>
</ion-content>
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as WC from 'woocommerce-api';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
WooCommerce: any;
products: any;
constructor(public navCtrl: NavController) {
this.WooCommerce = WC({
url: "http://localhost:8888/wordpress/",
consumerKey: 'ck_.....',
consumerSecret: 'cs_....',
wpAPI: true,
version: 'wc/v1'
});
this.WooCommerce.getAsync("products").then((data) =>{
console.log(JSON.parse(data.body));
this.products = JSON.parse(data.body);
console.log(typeof this.products);
}, (err) => {
console.log(err);
});
}
}