Created
December 21, 2017 16:09
-
-
Save rajesh-h/ba4442d53aa0566fe3c13f3979247cf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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