I'm displaying a list of items from an array using ng-option, however, only the first item from the array is displaying.
HTML -
<ng-select [multiple]="true">
<ng-option *ngFor="let result of selected">
{{result.medications.items[0].name}}
</ng-option>
</ng-select>
CodePudding user response:
<ng-select [multiple]="true">
<ng-option *ngFor="let res of result.medications.items">
{{res.name}}
</ng-option>
</ng-select>
You need to loop over the items in result.medications and display the name of each item as demonstrated above...
CodePudding user response:
you have to iterate through medications.items
.
<ng-select [multiple]="true">
<ng-option *ngFor="let result of medications.items">
{{result.name}}
</ng-option>
</ng-select>
CodePudding user response:
Try like this:
<ng-select [multiple]="true">
<ng-option *ngFor="let result of selected.medications.items">
{{result.name}}
</ng-option>
</ng-select>