Hi, Kindly need your advice.
i use metronic 8
I want to put data from api/ajax (json array) into Select control .
Below my html code:
<Field
as="select"
name="location"
:items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
data-control="select2"
data-allow-clear="true"
class="form-select form-select-lg"
id="ddlLocation"
>
</Field>
How the best practice to achieve that?
For your information, code above is not working also. Seem vue not recognize :items=
Hi, its work.
Thank you.
Hi,
Sorry for the late reply.
Are you using VeeValidate Field component?
To generate options from data fetched from your API, you can render the options element dynamically as shown below.
const stateOptions = ["California", "Colorado", "Florida", "Georgia", "Texas", "Wyoming"];
<Field name="state" as="select">
<option value="" disabled>Select a state</option>
<option v-for="state in stateOptions" :key="state" :value="state">
{{ state }}
</option>
</Field>