【问题标题】:Angular ui-select multiple clean ng-model valueAngular ui-select 多个干净的 ng-model 值
【发布时间】:2015-08-01 15:01:34
【问题描述】:

我正在尝试使用 ui-select 并且组件正在清理我的数组。

例子:

{{ vm.staff_hotels }}
<ui-select multiple ng-model="x" theme="bootstrap">
    <ui-select-match placeholder="Not selected">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="hotel.id as hotel in vm.hotels | filter: {active: true} | filter: $select.search">
        <div ng-bind-html="hotel.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>

我的变量“vm.staff_hotels”在屏幕上的值为 [1,2]。

{{ vm.staff_hotels }}
<ui-select multiple ng-model="vm.staff_hotels" theme="bootstrap">
    <ui-select-match placeholder="Not selected">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="hotel.id as hotel in vm.hotels | filter: {active: true} | filter: $select.search">
        <div ng-bind-html="hotel.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>

但是,如果我在 ng-model 中使用该变量,我的值将更改为 [null,null]。

【问题讨论】:

  • 有id为1和2的酒店吗?
  • 能否为您的问题创建一个 jsfiddle。
  • 这就是问题所在,我有相同的代码在另一个控制器中运行良好,所以,我需要知道为什么会发生这种情况,因为它不是默认行为。

标签: javascript html angularjs frontend ui-select


【解决方案1】:

我只需要更新我的 ui-select 的版本。

我以前用的是0.10.0版

我更新到 0.11.2 版本

只是一个错误!

【讨论】:

  • 六个放弃 50 来找出答案。很高兴你拿回来了
猜你喜欢
  • 1970-01-01
  • 2015-03-24
  • 1970-01-01
  • 2018-02-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-04
相关资源
最近更新 更多