import { Component, OnInit } from '@angular/core';
import { WpServiceService } from '../wp-service.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';


@Component({
  selector: 'app-news',
  templateUrl: './news.page.html',
  styleUrls: ['./news.page.scss'],
})
export class NewsPage implements OnInit {

    posts: any;
    
    constructor(private wpservice: WpServiceService,  private iab: InAppBrowser) { }

    ngOnInit() {
    }

    openLink(link) {
        const browser = this.iab.create(link, "_blank");
    }
    ionViewWillEnter() {
        this.wpservice.getPosts().then(res => {
            this.posts = JSON.parse(res['data']);
            console.log(this.posts);
        }, error => {
            console.log(error);
        });
    }

}
