Reputation: 653
I am getting values from the DB to the page where the dropdown box is there but the dropdown box not returning the value. The code as shown below,
methods: {
editState(id){
axios.defaults.headers.common['Authorization'] = "Bearer "+localStorage.getItem('token');
axios.get(baseUrl+'/state/edit/'+id)
.then((response) => {
alert(response.data[0].form.country_name);
this.form = response.data[0].form;
setTimeout(() => {
this.subComponentLoading = true;
}, 500);
})
.catch(function (error) {
console.log(error);
});
}
}
<d-field-group class="field-group field-row" label-for = "country_name" label="Country Name" label-class="col-4">
<d-select :options="Countries" v-model="form.country_id" id="country_id" name = "country_name" wrapper-class="col-7">
</d-select>
</d-field-group>
Upvotes: 0
Views: 168
Reputation: 164768
Two things that I see are wrong...
Countries
is inside the form
object but you don't assign or read it from there. Move it to the top level
You are binding a v-model
to form.country_id
but this does not initially exist. Add it to the form
object.
To summarise...
data () {
return {
isStateEditVisible: false,
form: {
state_name: '',
isStateEnabled: true,
ISO_Code: '',
country_id: '', // 👈 added this
country_name: '',
zone_name: ''
},
Countries: [], // 👈 moved this
Zones: [] // 👈 and this
}
}
In order to react to data changes, Vue needs to know about them up-front. See https://v2.vuejs.org/v2/guide/reactivity.html
Upvotes: 1