0

I have two selectboxes:

  • Language Select box
  • Some other Select box

Language

<select id="language" ng-model="languageID" ng-change="setLanguage()" 
ng-options="option for option in languages" ng-selected="languageID"></select>

Some other

<select id="weekTitle" ng-model="weekTitleID" ng-change="setWeekTitle()"
 ng-options="option for option in secondOptionsObject" ng-selected="weekTitleID">

Problem

When I set the language, the second box has to get it's options updated, for example:

English

Second select option one: "Hello" option two: "Hey there"

Dutch

Second select option one: "Hallo" option two: "Hallo daar"

Seems easy enough right? but when i first change the second box and then switchthe language, i get a white first option which is always selected, then When i switch back to the language i previously had it shows just two options (which is what i want). This is due to the fact that:

  1. The First Selectbox options are static ("English, Nederlands, Francais")
  2. The second selectbox options are dynamic ( This item is set everytime the language changes )

When this options object is changed by this line:

$scope.secondOptionsObject =  [$scope.language["firstOption"], 
                               $scope.language["secondOption"]] 

I get the white line, every object and index has been check thoroughly and have been proved to be correct. The only thing that doesn't happen appearantly is an update of the options in this piece of code:

 ng-options="option for option in secondOptionsObject"

When i do this, it works (but it's not what i want because the language changes):

$scope.secondOptionsObject =  ["option1", 
                               "option2"] 
ErikBrandsma
  • 1,661
  • 2
  • 20
  • 46
  • 1
    am CONFUSED , actually what the problem here? and what you want ? –  Oct 14 '14 at 12:36
  • The problem is that when the language changes, the second selectbox optionsobject gets updated in javascript properly, but in HTML, it is not being updated, hence, i'm getting a third white option because Angular cannot find the new language model in the old optionsobject ( using the old language ) – ErikBrandsma Oct 14 '14 at 12:44
  • The answer on this question solved the problem! http://stackoverflow.com/questions/12139152/how-to-set-value-property-in-angularjs-ng-options – ErikBrandsma Oct 20 '14 at 08:26

0 Answers0