Discussion icon indicating copy to clipboard operation
Discussion copied to clipboard

Can't access `text` of `option` in `select`

Open etelford opened this issue 10 years ago • 3 comments

I'm trying to access the text of a selected option by using Dynamic Select Options as described here: http://vuejs.org/guide/forms.html#Dynamic_Select_Options

I can retrieve the value but not the text.

<select v-model="newPayScale" options="payScaleOptions" number></select>

and:

payScaleOptions: [
    { text: 'Option 1', value: 1 },
    { text: 'Option 2', value: 2 }
]

What's the proper way to retrieve the selected text? Referencing {{ newPayScale.text }} doesn't work.

etelford avatar May 24 '15 00:05 etelford

This was somehow overlooked when I designed the options usage! For now you can use a computed property to loop through the options and find the text that matches the current newPayScale value.

yyx990803 avatar May 24 '15 01:05 yyx990803

Thanks!

etelford avatar May 24 '15 17:05 etelford

Has this been included yet?

avanderbergh avatar Jan 02 '16 21:01 avanderbergh