【发布时间】: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