<ui-select
ng-model="ruleSelected"
theme="bootstrap"
on-select="selectedItem($item)">
<ui-select-match>{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="o.name as o in rules | propsFilter: {name: $select.search}" position="down">
<div ng-bind-html="o.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
$scope.selectedItem = function(item) {
$scope.ruleSelected = item;
$scope.selected = item;
};
在下拉列表中选择值后,需要花费很多时间来设置$scope.ruleSelected
。有人可以帮我吗?
提前感谢
You do not have to pass a selected value into the ng-model.
when you select a value from the drop-down then ng-model bind that value.
you just have to pass as default
js code:
$scope.ruleSelected = '';
$scope.selectedItem = function(item) {
$scope.selected = item;
};
Reference link:
http://embed.plnkr.co/lWUBC7/