javascriptangularjsui-selectui-select2angular-ui-select

How to dynamically change the choices of ui select in angularjs


I have a couple of UI Selects, based on the selection of the first one I want to load the choices into the second one. How do I go about doing it dynamically for the second one. I did do some extensive searching but could not find anything.

<ui-select append-to-body="true"
           ng-model="requirementChoice" theme="bootstrap"
           ng-disabled="disabled" close-on-select="true"
           title="choose a requirement"
           theme="selectize"
           name="requirements" id="requirements">

    <ui-select-match placeholder="
             {{translations.SLA_CHOOSE_REQUIREMENTS}}">
        {{requirementChoice}}
    </ui-select-match>

    <ui-select-choices repeat="choice in requirementTypes |
                    filter:$select.search">
        {{choice}}
    </ui-select-choices>
</ui-select>

This is the first of my ui select which has the choices and based on these choices I want to load the data into the second UI select is there a way to achieve this?


Solution

  • Call a function on-select of the first ui-select and set the second ui-select accordingly in that function. Refer this https://github.com/angular-ui/ui-select/wiki/ui-select