angularjs ui-select set default value and can not select the default value -


i follow example in angularjs ui-select bootstrap website.

here html part code:

  <div class="form-group">     <div class="col-sm-6">       <ui-select ng-model="ctrl.person.selected" theme="bootstrap">         <ui-select-match placeholder="select or search person in list...">{{$select.selected.name}}</ui-select-match>         <ui-select-choices group-by="'country'" repeat="item in ctrl.people | filter: $select.search">           <span ng-bind-html="item.name | highlight: $select.search"></span>           <small ng-bind-html="item.email | highlight: $select.search"></small>         </ui-select-choices>       </ui-select> 

and here js part code:

  $scope.person = {};  $scope.people = [ { name: 'adam',      email: 'adam@email.com',      age: 12, country: 'united states' }, { name: 'amalie',    email: 'amalie@email.com',    age: 12, country: 'argentina' }, { name: 'estefanía', email: 'estefania@email.com', age: 21, country: 'argentina' }, { name: 'adrian',    email: 'adrian@email.com',    age: 21, country: 'ecuador' }, { name: 'wladimir',  email: 'wladimir@email.com',  age: 30, country: 'ecuador' }, { name: 'samantha',  email: 'samantha@email.com',  age: 30, country: 'united states' }, { name: 'nicole',    email: 'nicole@email.com',    age: 43, country: 'colombia' }, { name: 'natasha',   email: 'natasha@email.com',   age: 54, country: 'ecuador' }, { name: 'michael',   email: 'michael@email.com',   age: 15, country: 'colombia' }, { name: 'nicolás',   email: 'nicolas@email.com',    age: 43, country: 'colombia' }];    addoptions();   function addoptions(){       var tmp = { name: 'nis',   email: 'nis@email.com',    age: 43, country: 'china' };      $scope.people.push(tmp);      var tmp2 = {name: 'emma',   email: 'emma@email.com',    age: 43, country: 'china'};      $scope.people.push(tmp2);      $scope.person.selected = $scope.people[0];    } 

the dropdown list should right side, left sie:

enter image description here

also, noticed 1 thing, once set default person.select, $$haskkey of $scope.people[0], not exist anymore. version of ui select 0.17.1.

i had @ issue , made example cannot reproduce issue. check if having 0.17.1 or 0.17.2. in 0.17.2 have made changes selected value default gone. here's the example link

 -  

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -