{{$select.selected.name}} {{$select.selected.name}} {{$select.selected.name}}

on-select function call is very slow in ui-select angularjs

191 views Asked by At
<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;
};

it takes much time to set $scope.ruleSelected after selecting the value in the dropdown. Can somebody help me out?

Thanks in advance

1

There are 1 answers

0
mehta Pratik On
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/