After selection from ui select box, the selected option will not be attached (not displayed) as selected
I created a plunker for this: http://plnkr.co/edit/5nk4BnYoO52En7P6kPu9
Select a selection, but when you select one the ui-select will remain empty. Potentially important note: I am using this inside a (ui-bootstrap) directive. As a side note to this - there is no packing directive in the plunker, so this is not the culprit.
<ui-select search-enabled="true" ng-change="updateMedu()" style="width: 100%" ng-model="medications.chosenMedications.metadata.conceptGroup.conceptProperties">
<ui-select-match placeholder="Please click to choose or start typing dosage value..">{{$item}}</ui-select-match>
<ui-select-choices repeat="cp in medications.chosenMedications.metadata[key].conceptGroup[1].conceptProperties | filter: $select.search">
{{cp.synonym}}
</ui-select-choices>
</ui-select>
Manual dataset layout:
$scope.medications.chosenMedications.metadata = [
{
conceptGroup: [
{
conceptProperties: [
{synonym: "Item One"},
{synonym: "Item Two"},
{synonym: "Item Three"}
]
},
{
conceptProperties: [
{synonym: "Item A"},
{synonym: "Item B"},
{synonym: "Item C"}
]
}
]
}
];
+3
source to share
1 answer
Just try the following code:
<ui-select theme="select2" search-enabled="true" style="width: 100%"
ng-model="medications.chosenMedications.metadata.conceptGroup.conceptProperties">
<ui-select-match placeholder="Click to select or start typing...">
{{$select.selected.synonym}}
</ui-select-match>
<ui-select-choices repeat="cp in medications.chosenMedications.metadata[0].conceptGroup[1].conceptProperties | filter: $select.search">
{{cp.synonym}}
</ui-select-choices>
</ui-select>
Your problem is that you are trying to show {{$item}}
instead{{$select.selected.synonym}}
Hope this solves your problem.
Working demo: http://plnkr.co/edit/B3HTozs0MniWBpEj8L50?p=preview
+7
source to share