// interface
export interface IMovie {
id: number;
name: string;
releaseDate: string;
genre: string;
}
//component:
movie: IMovie = null;
ngOnInit() {
this.route.paramMap.subscribe((params: ParamMap) => {
const movie_id = parseInt(params.get('movie_id'), 10);
this.movieService.getMovieById(movie_id)
.subscribe((movie) => this.movie = movie);
});
}
//service
getMovieById(movie_id: number): Observable<IMovie> {
return this.http.get<IMovie>(url);
}
When I am trying to print in the component code I am able to see the Object (console.log(movie)
), I don't understand why the mapping i.e Object -> IMovie
is not happening.
I tried in different ways nothing worked for me.