-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovie-details.component.ts
More file actions
30 lines (27 loc) · 920 Bytes
/
movie-details.component.ts
File metadata and controls
30 lines (27 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MovieService } from '../movies/movie.service';
import { TMDBSingleResponse } from '../movies/tmdb-result';
import { Observable } from 'rxjs';
@Component({
selector: 'app-movie-details',
templateUrl: './movie-details.component.html',
styleUrls: ['./movie-details.component.scss'],
})
export class MovieDetailsComponent implements OnInit {
movieDetails$: Observable<TMDBSingleResponse>;
constructor(
private route: ActivatedRoute,
private movieService: MovieService,
private router: Router
) {}
ngOnInit(): void {
this.route.paramMap.subscribe((params) => {
this.movieDetails$ = this.movieService.getById(+params.get('id'));
});
}
removeFromCollection(id: number) {
this.movieService.removeFromCollectionById(id);
this.router.navigate(['/']);
}
}