I can't show an array of objects inside a template. This is part of my code:
Component.ts
export class UpcomingMoviesComponent implements OnInit {
movies: Movie[];
}
getUpcomingMovies() {
this.moviesRes = res.results;
let i = 0;
for (let item in this.moviesRes) {
for (let subItem in this.moviesRes[item]) {
this.movies.push(new Movie());
this.movies[i].id = this.moviesRes[item]["id"];
i++;
}
}
});
Template.html (I have tried several things but none of them worked)
<div *ngFor="let movie of this.movies">
{{movie.id}}
{{movie[0].id}}
</div>
If I use the following
{{this.movies | json}}
I get this:
[
{
"id":346672
}
]
Could you help me to show this object inside a template. thanks