2

I'm using ui-select within an ng-repeat to create a select box for each item over a collection. However, when I select a node ID in any of the individual select boxes it ends up getting selected in all of them. How can I configure the {{$select.selected.id}} part such that only the current choice select box gets updated? Here is the relevant code:

<div style="float:left; width:160px;" ng-repeat="choice in choices">
<div class="input-group">
    <ui-select ng-model="node.selected" theme="bootstrap" ng-disabled="disabled" reset-csearch-input="true" style="width:50px; float:left">
        <ui-select-match placeholder="{{choice.to_node_id}}">{{$select.selected.id}}</ui-select-match>
        <ui-select-choices repeat="node in nodes | filter: $select.search">
            <div ng-bind-html="node.id | highlight: $select.search" ng-click="updateChoiceLink(choice, node)"></div>
        </ui-select-choices>
    </ui-select>
</div>
3
  • 1
    if you define separate ng-model values for each of the selects this can be solved.If you provide a plunker i can demonstrate it Commented Mar 3, 2015 at 6:46
  • 1
    I changed ng-model to "choice.selected" and it works now :) Thanks a bunch! Commented Mar 3, 2015 at 6:56
  • 1
    post how you solved it and accept it as answer so incase someone got the same problem Commented Mar 3, 2015 at 6:57

1 Answer 1

5

I was able to solve the problem by binding the model to choice.selectedas opposed to node.selected. This way each select box has a unique ng-model based on the choice.

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

3 Comments

Hey, can you post your controller code? i am struck with same problem.
<ui-select multiple n-d="{{columnsTagObj.displayColumns[colValues.tag]}}" ng-model="columnsTagObj.displayColumns[colValues.tag]" theme="selectize" ng-disabled="disabled" reset-search-input="false" required> <ui-select-match>{{$item}}</ui-select-match> <ui-select-choices refresh="getDrugNameList($select.search)" refresh-delay="0" repeat="item in Druglist | filter:$select.search"> {{item}} </ui-select-choices> </ui-select>
I am using ng-repeat to create two input box of ui-select but the first one is showing blank and second one is showing both first and second value even the ng-model is different for each

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.