I am looking to implement a feature where a user can select checkboxes from a grouped list populated by an API call. When a checkbox is selected, I want to add the corresponding object to an array linked to the v-model of the checkbox input. Below are the details of the data fed into the checkboxes and my VUE and HTML code.
"data":[
{
"customerId":"046094",
"coreSystem":"symplusAM",
"accountId":"MMF046094001",
"fundName":"UNITED CAPITAL MONEY MARKET FUND"
},
{
"customerId":"046094",
"coreSystem":"symplusAM",
"accountId":"SIS046094001",
"fundName":"UNITED CAPITAL STAFF INVESTMENT SCHEME"
},
{
"customerId":"046094",
"coreSystem":"symplusAM",
"accountId":"EUROB046094001",
"fundName":"UNITED CAPITAL NIGERIAN EUROBOND FUND "
}
]
VUE Code:
<div style="padding-top:40px;" class="col s3">
<div class="input-field">
<h6 class="left-align">Select Portfolio Accounts</h6>
<template v-for="(item, key, index) in portfolioList">
<p>
<label>
<input v-model="selectedPortfolios[item]" :value="item" type="checkbox" class="filled-in" />
<span>
{{ item.fundName }}
</span>
</label>
</p>
</template>
</div>
</div>
I aim to update the selectedPortfolios array with specific fields - "customerId":"046094","coreSystem":"symplusAM","accountId":"MMF046094001" whenever a checkbox is ticked. How can I achieve this functionality in Vue?