New to Vue.js. Not sure where I am going wrong here. I have a dynamic list of users which you can add to. I also have a select that I want to stay recent with any model changes to the users. However, when I change the user information, the select is not being updated. I've attached the code and a Fiddle.
HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<div id="app">
<h1>Users</h1>
<div v-for="user in users">
User ID: <input type="text" v-model="user.id" /><br />
First Name: <input type="text" v-model="user.firstName" /><br />
Last Name: <input type="text" v-model="user.lastName" />
<br />
</div>
<input type="button" value="Add User" v-on:click="addUser" />
<br /><br />
This select should stay synced with what is entered above<br />
<select>
<option v-for="user in users" v-bind:value="user.firstName">{{user.firstName}} {{user.lastName}}</option>
</select>
</div>
JavaScript:
var app = new Vue({
el: "#app",
data: {
users: [{}]
},
methods: {
addUser: function() {
this.users.push({});
}
}
});
Fiddle: https://jsfiddle.net/rmekuuc3/