[on-select函数调用在ui-select angularjs中非常慢

问题描述 投票:0回答:1
<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。有人可以帮我吗?

提前感谢

html angularjs dropdown ui-select
1个回答
0
投票
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/
© www.soinside.com 2019 - 2024. All rights reserved.