我正在使用这个库:https://github.com/angular-ui/ui-select --我可以看到演示正常工作,但是当我尝试为我自己的目的修改它时,它不起作用。实际的控件本身似乎没有问题,但我指定的ng-model没有更新。
下面是一个plunkr,它展示了我的意思:http://plnkr.co/edit/xEtoR49Du9CdrNNoDWAa?p=preview
如果删除6M (例如),下面显示的数组selectedServices不会更新。
<ui-select multiple ng-model="selectedServices">
<ui-select-match placeholder="Services...">{{ $item }}</ui-select-match>
<ui-select-choices repeat="service in services | filter: $select.search">
{{ service }}
</ui-select-choices>
</ui-select>
{{ selectedServices }}和:
app.controller('DemoCtrl', function($scope, $http, $timeout) {
$scope.selectedServices = ['1M', '6M', '12M'];
$scope.services = ['1M', '6M', '12M'];
});发布于 2015-11-24 05:07:32
下面是使用相同示例的柱塞:http://plnkr.co/edit/3Rz09QUWOZFloLW0KfXF?p=preview
在用于ng模型的ui-select中,您需要创建空对象,并且需要为其赋值。
$scope.selectedServices = {};
$scope.selectedServices.values = ['1M', '6M', '12M'];https://stackoverflow.com/questions/33885315
复制相似问题