0

I have an array of objects,

movies = [
    {
    "_id": "61581aa12bee6cbe7b453d1d",
    "movie_title": "Master",
    "genres_list": [
    "Drama"
    ]
    },
    {
    "_id": "615c7f5fbc3bf7d026ee7f7e",
    "movie_title": "Sarpatta Parambarai",
    "genres_list": [
    "Drama",
    "Action",
    "Sports"
    ]
    },
    {
    "_id": "616d57c5653c0a4a55d9cb33",
    "movie_title": "OK Kanmani",
    "genres_list": [
    "Romance",
    "Drama",
    "Feel Good"
    ]
    }]

I want to display all the genres_list .

My code:

<div *ngFor="let movie of movies">
<span>{{movie.movie_title}}</span>
<div *ngFor = "let genre of movie.genres_list; let i=index">
<h2>{{genre[i]}}</h2>
</div>
</div>

I want to display all the genres_list values. Thank you :)

1 Answer 1

2

Just use <h2>{{genre}}</h2> in your html. Doing {{genre[i]}} is essentially treating the genre string as a character array and only prints out a single character of the string at index i.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.