选择角度ui-select时无法获取下拉数据

时间:2015-07-28 18:23:48

标签: angularjs typeahead ui-select angular-ui-select

我需要在选择ui-select时获取当前用户列表。所以,我使用ng-focus实现了它,并且它在ui-select的旧版本(0.8.3)中工作。但是使用最新版本的ui-select,它无法正常工作。它始终显示默认用户列表。

  <ui-select ng-model="user.selected" theme="bootstrap" ng-disabled="disabled" reset-search-input="true" style="width:300px" required>
    <ui-select-match placeholder="Choose One" style="border-color:#ccc;" ng-focus="getCurrentUsersList(user.selected)">{{$select.selected}}
      <button class="clear" ng-click="$event.stopPropagation();user.selected = undefined">x</button>
    </ui-select-match>
    <ui-select-choices repeat="user in usersList | highlight: $select.search" align="left">
      <div ng-bind-html="user | highlight: $select.search"></div>
    </ui-select-choices>
  </ui-select>

以下是plucker链接: http://plnkr.co/edit/VDZ41AIcd5cYwdA9fFPu?p=preview

1 个答案:

答案 0 :(得分:0)

使用ng-click

解决了这个问题
  <ui-select ng-model="user.selected" theme="bootstrap" ng-disabled="disabled" reset-search-input="true" style="width:300px" required>
    <ui-select-match placeholder="Choose One" style="border-color:#ccc;" ng-click="getCurrentUsersList(user.selected)">{{$select.selected}}
      <button class="clear" ng-click="$event.stopPropagation();user.selected = undefined">x</button>
    </ui-select-match>
    <ui-select-choices repeat="user in usersList | highlight: $select.search" align="left">
      <div ng-bind-html="user | highlight: $select.search"></div>
    </ui-select-choices>
  </ui-select>

这是plunker链接 http://plnkr.co/edit/VDZ41AIcd5cYwdA9fFPu?p=preview