*Note: if the fiddle isn't working, it's because code.angularjs.org is not 
responding... at least not for me. Hopefully this fixes itself soon. I'm 
intending to pull in the snapshot: *
*https://code.angularjs.org/snapshot/angular.min.js* 
<https://code.angularjs.org/snapshot/angular.min.js>

I am having an issue where my <select> box has nothing selected in it when 
the ngOptions key/value pair value is 0. Is this perhaps some issue where 
Angular takes the number zero to mean nothing is selected? Reference this 
jsfiddle: http://jsfiddle.net/cjry7yp2/10/ 

As you can see in the fiddle example, I have a collection of car options as 
key value pairs, and I'm using the ngOptions directive with them. For 
ng-model, I have a 'currentObject' that I'm switching out objects between. 
The problem is that when the value of the car option is zero, the drop-down 
doesn't show the selection on the first load up. So, effectively in my app, 
when switching to that view, the dropdown looks like nothing is selected. 
Note, if inspecting the HTML, the <option> does in fact have 
selected="selected" on it, but the dropdown doesn't reflect it visually.

To see the issue illustrated in the jsfiddle:
   1. Run the fiddle and click 'load first'. You should see the blue car 
label show up, as we've set the value of currentObject.car to 1.
   2. Change the loadFirst function so that it sets $scope.currentObject to 
item 0 of $scope.myObjects instead of item 1.
   3. Run the fiddle again and click 'load first'. Here, you see the object 
was loaded in as shown by the 'car 0 index 0' line in the output, but the 
dropdown shows nothing selected. The only difference here is that the value 
for 'red car' is zero. For instance, you should get the same behavior if 
instead you changed the value for 'blue car' to zero.

Any thoughts here?


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to