Javascript 从ui选择框进行选择后,所选选项不会像所选的那样粘住(不可见)

Javascript 从ui选择框进行选择后,所选选项不会像所选的那样粘住(不可见),javascript,angularjs,angularjs-directive,angular-ui,Javascript,Angularjs,Angularjs Directive,Angular Ui,我已经为此创建了一个plunker: 选择选项存在,但当您选择其中一个时,ui选择将留空。潜在的重要注意事项:我在一个指令(ui引导)中使用它。作为旁注,在plunker中没有包装指令,因此这不是罪魁祸首 <ui-select search-enabled="true" ng-change="updateMedu()" style="width: 100%" ng-model="medications.chosenMedications.metadata.conceptGroup.conc

我已经为此创建了一个plunker:

选择选项存在,但当您选择其中一个时,ui选择将留空。潜在的重要注意事项:我在一个指令(ui引导)中使用它。作为旁注,在plunker中没有包装指令,因此这不是罪魁祸首

<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>

请尝试以下代码:

<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>

{{$select.selected.synonym}
{{cp.synonym}}
您的问题是您试图显示
{{$item}}
,而不是
{{{$select.selected.synonym}

希望这能解决你的问题

工作演示:
<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>