[Vuejs]-Vue Js select dropdown selected not working in my Edit form using Laravel 5.4

0👍

Instead of :selected you need to use v-model on your select like this.

<div class="col-md-2">
    <label>Time</label>
    <div id="app-time">
        <select name="time" class="form-control" v-model="selectedValue">
            <option value="0">--Please Select--</option>
            <option v-for="time in times" :value="time.value">
                @{{ time.text }}
            </option>
        </select> 
    </div>
</div>

You can read more about it here

0👍

Don’t use json_encode method with double quoted string within interpolation, because it will generate string with enclosing in double quote.

echo json_encode('12:00 AM'); //"12:00 AM" 

Use interpolation with single quote

<option v-for="time in times" 
  v-bind:value="time.value" 
  :selected="time.value == '{{$getDeliveryReceipt['time']}}'"
 >{{time.text}}</option>

https://stackblitz.com/edit/vue-wqqydg?file=index.html

Leave a comment