0

我正在尝试进行分组 ui-select,实际上每个 ui-select 选项都取决于前一个。例如,我在第一个 UI-select 中有一个级别列表,然后根据第一个 ui-select 选择的项目,将在第二个 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]}]
4

1 回答 1

0

看看这个 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>
于 2016-09-03T01:54:05.237 回答