import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { WpdataService } from "../services/wpdata.service";
import { ModalController } from '@ionic/angular';

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

  newsdetaildata: any;
  data: any;

  constructor(private wpdataService: WpdataService, private route: ActivatedRoute, private router: Router, public modalController: ModalController) { }
  @Input() id: string;
  showDiss = false;

  ionViewWillEnter() {
    if (this.id != undefined) {
      this.showDiss = true;
    }
    console.log("showDiss ", this.showDiss);
    let id = this.route.snapshot.paramMap.get('id') || this.id;
    console.log("fetching ...");
    console.log(id);
    // this.wpdataService.getNewsDetail(id).subscribe((data) => {
    // console.log();
    this.wpdataService.getNewsDetail(id).subscribe(res => {
      this.data = res;
      console.log(this.data);
    });
  }


  ngOnInit() {
  }

}
