I'm using an ng-select for a field in a table, and I'm looking to get values from an array to populate and allow individual selections.
Below is the code the is being logged correctly, but I'm having some difficulty to get it to display. Currently the drop-down is empty, but the console log is as expected with all the expected data.
<ng-select [searchable]="false"
bindValue="name"
bindLabel="name"
[items]="serviceUsersMedication"
[(ngModel)]="serviceUsersMedication.name"
>
<ng-template ng-label-tmp let-item="item">
{{item.name}}
</ng-template>
</ng-select>
onSelect({selected}) {
this.selected = selected;
const filteredMeds = this.selected.filter(item => {
return item.medications;
});
this.serviceUsersMedication = filteredMeds.map(item => {
return item.medications;
});
console.log('Selected:');
console.log(this.selected);
console.log('Service users medication:');
console.log(this.serviceUsersMedication);
}
this.selected is a variable that stores an array of a user's information when selecting from a row.
this.serviceUsersMedication is a variable that holds their meds from the selection.
I'm looking to display the name field from the array in the dropdown.