【问题标题】:How to change the choice list in ui-select?如何更改 ui-select 中的选择列表?
【发布时间】:2017-01-17 21:36:59
【问题描述】:

我有一个基本的 ui-select 组件,以及一个为 ui-select 获取另一个列表的案例。

当单击按钮或通过其他函数调用时,如何将此处的“somelist”更改为“anotherlist”)?

<ui-select ng-model="obj.selected"> 
    <ui-select-match>{{$select.selected.dsc}}</ui-select-match>
    <ui-select-choices repeat=" X in somelist | propsFilter: {dsc: $select.search}">
        <div ng-bind-html="X.dsc | highlight: $select.search" position='down'></div>
    </ui-select-choices>
</ui-select>

<button>Change list</button>

【问题讨论】:

  • anotherlist 而不是somelist。 :O
  • 以编程方式?
  • 它周围一定有一些条件,对吧?根据条件执行 ng-if 或 ng-show/hide。
  • @sisyphus,你的意思是用 ng-if 写两次所有的 ui-select 标签?
  • &lt;button ng-click="somelist = ['new item']"&gt;Change list&lt;/button&gt;

标签: javascript angularjs ui-select


【解决方案1】:

我得到了这个解决方案;

我猜当somelist 得到undefined 然后又被填充时,ui-select 会刷新。所以这对我有用:

somelist = undefined;
somelist = anotherlist;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-17
    • 2020-03-23
    • 2020-12-29
    • 1970-01-01
    • 2016-12-31
    • 2018-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多