How to get the object of selected option?



  • In the example below:

    ...
    <q-select color="secondary" v-model="select" :options="listOptions" />
    ...
    select: 'fb',
    listOptions: [
            {
              label: 'Google',
              icon: 'email',
              value: 'goog'
            },
            {
              label: 'Facebook',
              icon: 'chat',
              description: 'Enables communication',
              value: 'fb'
            },
            {
              label: 'Twitter',
              inset: true,
              rightIcon: 'live_help',
              value: 'twtr'
            },
            {
              label: 'Apple Inc.',
              inset: true,
              stamp: '10 min',
              value: 'appl'
            },
            {
              label: 'Oracle',
              description: 'Some Java for today?',
              icon: 'unarchive',
              rightIcon: 'widgets',
              value: 'ora'
            }
          ]
    ...
    

    If the user select Oracle, how to get the other properties like label, icon and description, etc…?
    The selection property should store the full object, not just the value.



  • Here you go:

    ...
    <q-select color="secondary" v-model="select" :options="listOptions" />
    ...
    select: {
      label: 'Google',
      icon: 'email',
      value: 'goog'
    }.
    listOptions: [
            {
              label: 'Google',
              icon: 'email',
              value: {
                label: 'Google',
                icon: 'email',
                value: 'goog'
              }
            },
            {
              label: 'Facebook',
              icon: 'chat',
              description: 'Enables communication',
              value: {
                label: 'Facebook',
                icon: 'chat',
                description: 'Enables communication',
                value: 'fb'
              }
            }
          ]
    ...
    

Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.