I'd like to access the "newest" object of a nested object array inside another object array in Vue.js. Please see the example below.
Example Object elements:
[
{
'name': 'foo',
'content': [
{
title: 'bar'
}
]
},
{
'name': 'hello world',
'content': [
{
'title': 'this is a test'
},
{
'title': 'this another test'
}
]
}
]
Simplified vue code:
<div v-for="{ element, index } in elements" :key="index">
<h1>{{ element.name }}</h1>
<p>Latest content: {{ element.content[element.content.length - 1].title }}</p>
</div>
Why is that not working? Vue says that element.content is undefined.