Closed subhasishnath45 closed 5 years ago
@subhasishnath45 I'm sorry, but I don't understand the issue you're having. Could you please create a minimal reproduction somewhere or clarify your question?
Thanks for the issue! Please visit our forum or slack channel for questions about the framework. :smile:
If you have an idea for how we can improve the documentation, please open a new issue and fill out the provided template. Thanks!
`import { Component } from '@angular/core'; import { NavController, NavParams, AlertController, Platform, ToastController } from 'ionic-angular'; import { ApiProvider } from '../../providers/api/api'; import { TruncatePipe } from '../../pipes/truncate/truncate'; import { KitchenDetailsPage } from '../kitchen-details/kitchen-details'; import { Network } from '@ionic-native/network'; import { errorHandler } from '@angular/platform-browser/src/browser';
@Component({ selector: 'page-home', templateUrl: 'home.html', // pipes: [TruncatePipe] }) export class HomePage { // following variable will hold single kitchen item in home page public kitchenitems:any = [];
public carouselItems:any = [];
// initially showing 5 latest posts, 5 posts at a time private per_page:number = 5; // initially shows page 1 private page:number = 1; private showLoadMore:boolean = false; private isLoading = false;
constructor(public navCtrl: NavController, public api:ApiProvider, public navParams:NavParams, private network:Network,public alertCtrl:AlertController,public platform:Platform, public toast:ToastController) { // watch network for a connection this.network.onConnect().subscribe(()=>{ this.toast.create({ message : 'Network connected.', duration: 3000 }).present(); });
}
getKitchenPosts(){ if(!this.isLoading){ this.isLoading = true; // http://dlive.in/khobor/khonjkhobor/wp-json/wp/v2/Allkitchenposts-api?_embed&per_page=5&page=1 this.api.get('Allkitchenposts-api?_embed&per_page=' + this.per_page + '&page=' + this.page).subscribe((data:any) =>{ this.isLoading = false; this.kitchenitems = this.kitchenitems.concat(data); // data.length will tell us how many json objects are there in our json array. // this.per_page is 5 here // if No of json objects === 5 then don't show load more button. if(data.length === this.per_page){ this.page++; this.showLoadMore = true; }else{ this.showLoadMore = false; }
} getHomeCarousels(){ if(!this.isLoading){ this.isLoading = true; // http://dlive.in/khobor/khonjkhobor/wp-json/wp/v2/Allkitchenposts-api?_embed&per_page=5&page=1 this.api.get('homeCarousel-api?_embed&per_page=' + this.per_page + '&page=' + this.page).subscribe((data:any) =>{ this.isLoading = false; this.carouselItems = this.carouselItems.concat(data); // data.length will tell us how many json objects are there in our json array. // this.per_page is 5 here // if No of json objects === 5 then don't show load more button. if(data.length === this.per_page){ this.page++; this.showLoadMore = true; }else{ this.showLoadMore = false; }
} openKitchenDetails(kitchenitem){ // 1st parameter is page name // 2nd parameter is post of type kitchenitem this.navCtrl.push(KitchenDetailsPage,{post: kitchenitem}); }
getCatName(cat_id:number):string{ let cat_name:string = ''; this.api.Categories.forEach(element => { if(element.id == cat_id){ cat_name = element.name; } }); return cat_name; } ionViewDidLoad() {
}
} `