0

I need to fetch the current users list on selecting the ui-select. So, I have implemented it using the ng-focus and it is working in older version(0.8.3) of ui-select. But with the latest version of ui-select, it is not working. It is always showing the default users list.

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

Here is the plucker link: http://plnkr.co/edit/VDZ41AIcd5cYwdA9fFPu?p=preview

SaiGiridhar
  • 886
  • 1
  • 13
  • 28
  • You could just do – Liam Jul 28 '15 at 18:38
  • Then, only for the first time, when ui-select box is being rendered, it fetches the users list. But later again, when we try to change the selected user in it, it will not fetch the users list. I want it to be called everytime whenever we try to select something in the ui-select – SaiGiridhar Jul 29 '15 at 02:22

1 Answers1

0

Solved this using 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>

Here is the plunker link http://plnkr.co/edit/VDZ41AIcd5cYwdA9fFPu?p=preview

SaiGiridhar
  • 886
  • 1
  • 13
  • 28