I have a v-autocomplete component on my template and I would like display data via item-text. The first value ${item.name} is will always be rendered but the second value ${item.faculty.name} comes from a nested relationship and I want to make it optional( if exist then display and if it null then display nothing). How can achieve it.
<v-autocomplete
v-model="form.classroom"
:items="classrooms"
:item-text="item => `${item.name} - ${item.faculty.name}`"
item-value="id"
:label="$t('GENERAL.ALL.CLASS_ROOM')"
hide-selected
clearable
prepend-icon="mdi-chair-school"
:error-messages="serverValidation.getMessage('classroom')"
></v-autocomplete>
The first value is displaying without problem.
computedvalue, it makes it easier to deal with if you put that logic into your js code.