关联 Angular ui-select

associated Angular ui-select

我正在尝试分组 ui-select,实际上每个 ui-select 选项都取决于前一个选项。 例如,我在第一个 UI-select 中有一个级别列表,然后根据第一个 ui-select selected Item 列表位号将显示在第二个ui-select。 那可能吗? 这是我的代码,但我还不能实现它:(

<div class="SumoSelect sumo_somename" tabindex="0" style="width:80%">
        <ui-select search-enabled=false ng-model="levelNumber.selected"
                        theme="bootstrap" append-to-body="true" on-select="getListPlacePerLevel(levelNumber.selected)">
                    <ui-select-match placeholder="">{{$select.selected.levelNumber}}</ui-select-match>
                    <ui-select-choices repeat="item in levels">
                    <span ng-bind="item.levelNumber"></span> </ui-select-choices> </ui-select>
    </div>
    <div class="SumoSelect sumo_somename" tabindex="0" style="width:80%; margin-top:20px;">
        <ui-select search-enabled=false ng-model="item.selected"
                        theme="bootstrap" append-to-body="true">
                    <ui-select-match placeholder="">{{$select.selected.item}}</ui-select-match>
                    <ui-select-choices repeat="item in levelNumber.selected.listPlaceNumber">
                    <span ng-bind="item"></span> </ui-select-choices> </ui-select>
    </div>

我的Json数据如下

[{"levelNumber":1,"listPlaceNumber":[1,2,3,4,6]},{"levelNumber":2,"listPlaceNumber":[2,4,6,7]},{"levelNumber":3,"listPlaceNumber":[11,12,13,14,16]}]

看看这个 plunk 是否适合你:

http://plnkr.co/edit/2kiQ7W?p=preview

相关代码:

<div tabindex="0" style="width:80%">
    <ui-select search-enabled="false" ng-model="levelNumber.selected" theme="bootstrap" append-to-body="true" on-select="getListPlacePerLevel(levelNumber.selected)">
        <ui-select-match placeholder="">{{$select.selected.levelNumber}}</ui-select-match>
        <ui-select-choices repeat="item in levels">
            <span ng-bind="item.levelNumber"></span>
        </ui-select-choices>
    </ui-select>
</div>
<div tabindex="0" style="width:80%; margin-top:20px;">
    <ui-select search-enabled="false" ng-model="item.selected" theme="bootstrap" append-to-body="true" on-select="getListPlacePerLevel($select.selected)">
        <ui-select-match placeholder="">{{$select.selected}}</ui-select-match>
        <ui-select-choices repeat="item in levelNumber.selected.listPlaceNumber">
            <span ng-bind="item"></span>
        </ui-select-choices>
    </ui-select>
</div>