There is an object structured like this:
groupedContacts:
{
4: [
{name: 'foo'},
{name: 'bar'}
],
6: [
{name: 'foo bar'},
]
}
Additionally, we have another array:
companyList.models:
models: [
{id:4, name: 'company A'},
{id:6, name: 'company B'},
]
The IDs in the companies correspond to keys in groupedContacts. One array contains company names and the other includes contact details for these companies.
The goal is to display them in multiple tables like so:
Table 1
Company A (id4)
- foo
- bar
Table2
Company B (id6)
- foo bar
Despite the following code, there are no errors but the tables do not show any contacts:
<div
v-for="(company, key) in companyList.models"
:key="key"
class="table table--hover mt-4"
>
<h4 class="mb-4" v-html="company.name" />
<table>
<thead>
<tr>
<th class="text-left" v-html="__t('name')" />
</tr>
</thead>
<tbody
v-for="(groupContacts, key) in groupedContacts"
:key="key"
v-if="company.id === key"
>
<tr
v-for="(contact, contactKey) in groupContacts"
:key="contactKey"
>
<td v-html="contact.name" />
</tr>
</tbody>
</table>
</div>
View the result achieved in the browser by clicking on this link.