1

I am using angular ui select https://github.com/angular-ui/ui-select in my project. I am using ui-select directive

My code:

<select class="input-small" ng-model="dashboard.style" ng-options="f for f in ['light','hpexp']" ng-change="styleUpdated()"></select>

I want to use ui-select So I did,

<ui-select id="viewSelector"
    class="viewSelector input-small"
    ng-model="dashboard.style"
    ng-options="f for f in ['light','hpexp']" 
    ng-change="styleUpdated()"
    theme="selectize"> 
<ui-select-match placeholder="-- Select --">
   {{$select.style}}</ui-select-match>
</ui-select>

But it is not working. How to use ng-options in ui-select

Thanks!!

2
  • Can you add this code in fiddler? Commented Sep 7, 2015 at 6:22
  • sure.. let me try... Commented Sep 7, 2015 at 6:23

1 Answer 1

1

Please use ui-select-choices instead of ng-options. Lets try the below code, instead of yours

<ui-select id="viewSelector"
        class="viewSelector input-small"
        ng-model="dashboard.style"  
        ng-change="styleUpdated()"
        theme="selectize"> 
    <ui-select-match placeholder="-- Select --">
       {{$select.style}}</ui-select-match>
    <ui-select-choices repeat="f for f in ['light','hpexp']">
          <div ng-bind-html="f"></div>
        </ui-select-choices>
    </ui-select>

More details, please read this discussion

Angularjs and UI-Select: how to select an option from code

Sign up to request clarification or add additional context in comments.

3 Comments

Expected expression in form of 'item in collection_[ track by _id]' but got 'f for f in ['light','hpexp']'. Getting this error
Thanks, Try this repeat="f in ['light','hpexp']"
but on select of any option.. <ui-select-match placeholder="-- Select Style--"> {{$select.style}}</ui-select-match> it is not displaying anything.. if you can help it will be awesome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.