0
<b-form-select
   v-model="form.depart"
   :options="department"
   class="depart"
   required
></b-form-select>

My coming array of object is:

[
   { id: 1, department_name: 'CSE', department_email: '[email protected]'},
   { id: 2, department_name: 'EEE', department_email: '[email protected]'},
]

This data is not loading in the Select Option. I want just department_name in the select option. Given NULL.

2 Answers 2

2

Please specify your text-field and value field if these are not value and text in the array of objects. Check with the below code

<b-form-select
   v-model="form.depart"
   :options="department"
   class="depart"
   required
   value-field="department_name"
   text-field="department_name"
></b-form-select>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer. Can you help me for another query? I want to add Select Department in the department array. How is this possible?
0

Input field

  <b-form-select
    v-model="depart"
    :options="department"
    class="depart"
    required
    value-field="department_name"
    text-field="department_name"
  ></b-form-select>

To add the "Select department" option add the following:

data() {
  return {
    depart: 'Select department',
    department: [{
        id: 0,
        department_name: 'Select department',
        disabled: true
      },
      {
        id: 1,
        department_name: 'CSE',
        department_email: '[email protected]'
      },
      {
        id: 2,
        department_name: 'EEE',
        department_email: '[email protected]'
      },
    ]

  }
}

Here is a working version https://jsfiddle.net/g3kLqscy/

2 Comments

There is no difference with the previous answer. Thank you.
You asked how to add this to your array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.