Skip to content

Instantly share code, notes, and snippets.

@rajesh-h
Created December 21, 2017 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajesh-h/ba4442d53aa0566fe3c13f3979247cf6 to your computer and use it in GitHub Desktop.
Save rajesh-h/ba4442d53aa0566fe3c13f3979247cf6 to your computer and use it in GitHub Desktop.
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';
import { WpApiPosts } from 'wp-api-angular';
import { Observable } from 'rxjs';
import { URLSearchParams } from '@angular/http';
import { AppearIn } from './../../../src/utils/animations';
import { IListComponent } from './../../../src/interfaces';
import { ListParentComponent } from './../../../src/ListParent';
/**
* Generated class for the CustomHomePage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-custom-home',
templateUrl: 'custom-home.html',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [AppearIn],
})
export class CustomHomePage extends ListParentComponent implements IListComponent{
title: string;
posts$: Observable<any>;
slides:any;
constructor(
private wpApiPosts: WpApiPosts,
public navCtrl: NavController,
public cdRef: ChangeDetectorRef,
) {
super(wpApiPosts, navCtrl, cdRef);
//Get Latest 3 posts
let uRLSearchParams = new URLSearchParams();
uRLSearchParams.append('per_page', '3' );
//uRLSearchParams.append('categories', '4');
this.wpApiPosts.getList({ search: uRLSearchParams })
.map(response => response.json())
.subscribe(data => {
console.log(data);
this.slides = data; })
//console.log(this.slides)
this.title = 'Cooking Shooking';
}
ionViewDidLoad() {
console.log('ionViewDidLoad CustomHomePage');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment