I am having trouble implementing ngx dropdown list in this way:
<ngx-dropdown-list [items]="categoryItems" id="categoriesofdata" [multiSelection]="true"
[placeHolder]="'Select categories'"></ngx-dropdown-list>
After selecting items, I want to retrieve only the selected values like so:
get selectedCategories() {
const items = this.categoryItems.filter((item: any) => item.selected);
return items.length ? JSON.stringify(items.map(item => ({
value: item.value
}))) : '';
}
The output currently displays as:
[{"value":"Surname"},{"value":"Address"}]
However, I would like to retrieve just 'Surname' instead of 'value' and 'Surname'.
[0].value
What is the best approach to achieve this?
Should I use a for loop or is there a better option available?