My component
export class MoviedetailComponent implements OnInit {
movie:any
constructor(
private getmovie: GetmovieService,
private router: Router,
private rout: ActivatedRoute
) { }
ngOnInit() {
this.rout.params
.switchMap((params: Params) =>
this.getmovie.getMovieById(+params['id']))
.subscribe(movie => {
this.movie = movie;
console.log(this.movie);
});
}
}
my html
<p>{{movie.title}}</p>
So when I load the page, it shows the content of movie.tittle, but there is also an error in console saying "Cannot read property 'title' of undefined"
Any ideas?