import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NavController } from '@ionic/angular';
import Parse from "parse";

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

  constructor(private route:ActivatedRoute,
    private navCtrl:NavController
  ) { }

  ngOnInit() {
    this.loadFilmById()
  }

  film:Parse.Object|undefined
  async loadFilmById(){
    // let id = location.pathname.split("/").pop();
    let id = this.route.snapshot.params["id"]

    if(id){
      let query = new Parse.Query("Film");
      this.film = await query.get(id);
    }
  }

  goToBack()
  {
    this.navCtrl.back();
  }

}
