import { Component,OnInit,ViewEncapsulation } from '@angular/core';
import { LoadingController,NavController,ModalController } from '@ionic/angular';
import { Router } from '@angular/router';
import { WordPressRestapiService, Post } from '../../providers/wordpress-service';
/*
Generated class for the Posts page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-posts',
templateUrl: 'posts.html',
styleUrls: ['posts.scss'],
encapsulation: ViewEncapsulation.None
})
export class PostsPage {
categoryId: number;
private posts : Post[] = [];
constructor(
public loadingController: LoadingController,
private wordpressService: WordPressRestapiService,
public navCtrl: NavController,
public router: Router,
public modalView: ModalController) { }
async ngOnInit() {
const loading = await this.loadingController.create();
await loading.present();
this.loadPosts().subscribe(res => {
this.posts = [...this.posts, ...res];
loading.dismiss();
});
}
loadPosts() {
return this.wordpressService.getRecentPosts(this.categoryId);
}
openPost(postId) {
this.router.navigateByUrl('/singlepost/' + postId);
this.modalView.dismiss();
}
}
import { Component,OnInit,ViewEncapsulation } from '@angular/core';
import { LoadingController,NavController,ModalController } from '@ionic/angular';
import { Router } from '@angular/router';
import { WordPressRestapiService, Post } from '../../providers/wordpress-service';
/*
Generated class for the Posts page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-posts',
templateUrl: 'posts.html',
styleUrls: ['posts.scss'],
encapsulation: ViewEncapsulation.None
})
export class PostsPage {
categoryId: number;
private posts : Post[] = [];
constructor(
public loadingController: LoadingController,
private wordpressService: WordPressRestapiService,
public navCtrl: NavController,
public router: Router,
public modalView: ModalController) { }
async ngOnInit() {
const loading = await this.loadingController.create();
await loading.present();
this.loadPosts().subscribe(res => {
this.posts = [...this.posts, ...res];
loading.dismiss();
});
}
loadPosts() {
return this.wordpressService.getRecentPosts(this.categoryId);
}
openPost(postId) {
this.router.navigateByUrl('/singlepost/' + postId);
this.modalView.dismiss();
}
}