Angular-chosen: selected value not displayed immediately

133 views Asked by At

I'm using angular-chosen in my angular application. I have in a modal, different inputs and a select chosen. The modal let the user add or edit person's informations. My problem is that in the edit mode, the selected value of the chosen is not displayed at the first time. It's just when I reopen the modal that I can see the selected value. I verified if the data takes too much time to be loaded, but it seems like it's a problem with the chosen and the modal. This is how I display it:

 <select id="school" name="school" 
   no-results-text="'No data'" chosen
     disable-search-threshold="1" ng-model="person.school"
     ng-options="school as school.name + ' - ' + school.districtName + ' - ' + school.regionName  + ' - ' + school.cityName  for school in schools track by school.id">
          <option value="">&nbsp;</option>
   </select>
1

There are 1 answers

0
DelhiPanda On

You have to start it from the controller because ng-model is undefined and no '' or the value you want to choose person.school = '' or maybe in a ng-init="person.school = ''" in the select tag