Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { MovieService } from '../movie.service';
  3.  
  4. @Component({
  5. selector: 'app-home',
  6. templateUrl: './home.component.html',
  7. styleUrls: ['./home.component.css']
  8. })
  9. export class HomeComponent implements OnInit {
  10. popular_movies: any;
  11. upcoming_movies: any;
  12. search_result: any;
  13. movie: any;
  14.  
  15. constructor(public movieService: MovieService) {
  16. // get upcoming movies
  17. this.movieService.getUpcomingMovies().subscribe(data => {
  18. this.upcoming_movies = data['results'];
  19. // console.log(this.upcoming_movies);
  20. });
  21.  
  22. // get popular movies
  23. this.movieService.getPopularMovies().subscribe(data => {
  24. this.popular_movies = data['results'];
  25. // console.log(this.popular_movies);
  26. });
  27.  
  28. }
  29.  
  30. // get search results of movies
  31. searchMovies() {
  32. this.movieService.searchMovie(this.movie).subscribe(data => {
  33. this.search_result = data['results'];
  34. // console.log(this.search_result);
  35. });
  36. }
  37.  
  38. ngOnInit() {
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment