Charrua
86
2
Vue

Trying to load selected value on select

Posted 1 month ago by Charrua

Hello I have an issue loading the selected option of a select input. Here is my code, items is the object I want to populate with the products object

<div v-for="(article) in items">
    <select v-model="article.product">
        <option v-for="(product) in products" :value="product">
            {{ product.name }} 
        </option>
    </select>
</div>

If I run this code I get the product object inside each item object as expected. The problem is the reverse situation, if start the items object populated on page load, the selected option is not selected.

I have found a way for the select to work and is to change the value of the option, instead to use the product object, use a property as product.name and the same on the select model article.product.name. The issue is that I need the value of each option to populate the item.product object.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.