The New Way to Build! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Learn More

inject option data from api into Select control


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=


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


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>


Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(