I am trying to access the value. If I give {Movie.Score}
, the score will print. In,
[{"score":0.70159364,"show":{"id":34653,"url":"https://www.tvmaze.com/shows/34653/all-american","name":"All American","type":"Scripted","language":"English",
I want to print names. I am using {movie.name}
and {movie.score.name}
, but it’s not printing.
2
Answers
Assumming that your array looks like this, you have to first tell your code which element in your array you want to access to so you write
movie[index].show.name
If
movie
is your array then you have to acces each element by it’s index.and also
movie.score.name
won’t work becuzname
is not a property inside thescore
keyYou can access by console.log(‘movie name ‘, this.item[0][‘show’][‘name’]);
Demo below.
https://stackblitz.com/edit/angular-ja2m6n?file=src%2Fmain.ts