Search code examples
angularjshtmlangular-ui-select

angular ui-select is not working for array list and first o value


Angular ui-select is not working. If I select first option 0 it is coming like this..

<h3>New List 2</h3>
  <p>Selected: {{panel.fill}}</p>
  <ui-select id="viewSelector" ng-model="panel.fill" theme="selectize">
    <ui-select-match placeholder="Select">{{$select.selected}}</ui-select-match>
    <ui-select-choices repeat="f in [0,1,2,3,4,5,6,7,8,9,10]">
      <div ng-bind-html="f"></div>
    </ui-select-choices>
  </ui-select>

enter image description here

enter image description here Please see the demo.

http://plnkr.co/edit/CKHbiSQ4tZXTjOyxpyBK?p=preview

Please guide me.


Solution

  • It doesn't like the number 0 that is your first option, it's a false-y value, which is likely confusing the directive on whether it should display the placeholder or not.

    It works as expected if you change your array to be the string representation of the numbers, because string "0" is not false-y:

    <ui-select-choices repeat="f in ['0','1','2','3','4','5','6','7','8','9','10']">