Below is my code I have combobox values in my activityOptions but my combobox does not displays anything. Please help me with this issue.
.js
// Complete activity
for (let v of this.activity) {
this.complete_activity.push(v.option);
this.dropDown["Complete Activity?"] = this.complete_activity;
// console.log('this.complete_activity : '+this.complete_activity);
}
this.activityOptions = [{label : this.complete_activity, value : this.complete_activity}];
console.log('this.activityOptions : '+JSON.stringify(this.activityOptions));
.html
<template>
<lightning-card>
Hello
<lightning-combobox name="SelectOption" label="Complete Activity?"
options={activityOptions}
required>
</lightning-combobox>
</lightning-card>
</template>
Best Answer
As stated in the documentation:
So
activityOptions
must be an array of object with two string properties:label
andvalue
.Instead, as shown by the console.log, you created and array with a single element whose
label
andvalue
properties are arrays:In order to fix it, you should modify your for-loop:
Please note that special characters must be escaped. I.E. if you want to display
"Hello World"
the label should belabel: '\"Hello World\"'
.