Created
January 24, 2019 04:17
-
-
Save saimon24/c7c7643671372431e36ee9fc3a6cdb67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { MovieService } from './../../services/movie.service'; | |
import { Component, OnInit } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
@Component({ | |
selector: 'app-movie-details', | |
templateUrl: './movie-details.page.html', | |
styleUrls: ['./movie-details.page.scss'], | |
}) | |
export class MovieDetailsPage implements OnInit { | |
information = null; | |
/** | |
* Constructor of our details page | |
* @param activatedRoute Information about the route we are on | |
* @param movieService The movie Service to get data | |
*/ | |
constructor(private activatedRoute: ActivatedRoute, private movieService: MovieService) { } | |
ngOnInit() { | |
// Get the ID that was passed with the URL | |
let id = this.activatedRoute.snapshot.paramMap.get('id'); | |
// Get the information from the API | |
this.movieService.getDetails(id).subscribe(result => { | |
this.information = result; | |
}); | |
} | |
openWebsite() { | |
window.open(this.information.Website, '_blank'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment