【问题标题】:How to dynamically change the choices of ui select in angularjs如何在angularjs中动态更改ui select的选择
【发布时间】:2017-07-19 00:53:23
【问题描述】:

我有几个 UI 选择,基于第一个的选择,我想将选择加载到第二个中。我该如何为第二个动态做呢。我确实做了一些广泛的搜索,但找不到任何东西。

<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>

这是我的第一个 UI 选择,它有选择,基于这些选择,我想将数据加载到第二个 UI 选择中,有没有办法实现这一点?

【问题讨论】:

  • 你能创建一个虚拟的 jsfiddle 或 plunkr。在选择第一个 ui-select 时,您可以在第二个中重置选项...这完全取决于您如何设置选项。
  • 谢谢我明白了我根据第一个 ui-select 中选择的选项更改了第二个 ui-select 的数组。

标签: javascript angularjs ui-select ui-select2 angular-ui-select


【解决方案1】:

调用第一个 ui-select 的函数 on-select 并在该函数中相应地设置第二个 ui-select。 参考这个https://github.com/angular-ui/ui-select/wiki/ui-select

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 2014-10-02
    • 2015-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    相关资源
    最近更新 更多