0

In AdonisJS, I can't figure out why i keep getting "undefined" in my dropdown menu. My form uses the v-for directive to loop through "test" which is an array of objects, so i am expecting the dropdown to show the item.name but it shows "undefined". Can anyone help a newbee AdonisJS learner. Thanks Below is my code. PS: the same code works in outside of AdonisJS, when i save the file as a plain .html file.

    <html>

    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>


<div id="app">


<form action="/" method="POST">
 
    <select v-model="Selected">
        <option v-for="item in test" v-bind:value="item.name" >
            {{ item.name }}
        </option>
    </select>

    <input type="submit" value="Submit" class="btn btn-primary">
  </form> 

</div> 
 
<script>

        new Vue({
        
                el: '#app',
        
                data: {



                    test: [
                            { id:1, name:"adam"},
                            { id:2, name:"lena"},
                            { id:3, name:"hamza"},
                    ],

                    Selected: "",
    
                },
                    
                
        })
        
    </script>
  
  

</body>
</html>
  • 1
    It seems to work [JsFiddle](https://jsfiddle.net/vdpstrug/) – RDU Aug 21 '21 at 15:53
  • Yes, i just tried it outside of the framework i was using i.e. AdonisJs so i have modified my question. Thank you so much. It seems i have just wasted 2 hours of my time thinking my code was wrong. – Medical Doctor - Programmer Aug 21 '21 at 15:57

0 Answers0