My API returns a JSON response my Angular application picks-up using an Interface. The JSON that gets returned looks like this:
{
"release_date":"2012-03-14",
"genre_relation":[
{
"id":"2604ebbf-4eb5-46e3-89d8-ab4e8ecc8275",
"name":"ABC"
},
{
"id":"5267a0c6-9423-4e28-a413-133cc3435612",
"name":"DEF"
},
{
"id":"13d1454a-fc0e-457c-9f8e-9a9952984d8c",
"name":"GHI"
}
]
}
Now my question, How I can access the name field of the response as it nested? For example, if I do the following at my template:
<p>{{ api_response.genre_relation.name }}</p>
.name is not resolving. Do I have to do this on Interface level? Currently, my Interface looks really flat:
export interface SomeResponse {
release_date: string;
genre_relation: string;
}
Kind regards and thanks in advance.
export interface GenreRelation { id: string, name: string }. then replacegenre_relation: stringbygenre_relation: Array<GenreRelation>.