0

我需要在选择 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>

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

4

1 回答 1

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

于 2015-07-29T16:32:49.613 回答