You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
On upgrading from angular 1.2.23 to 1.3.15 I noticed a bug when select elements are bound using ng-model to a scope property which is predefined as null. These elements render an additional option elements which looks like <option value="? object:null ?"></option>, the result of this as an extra blank option on the dropdown.
The following code sample demonstrates the problem by comparing a select bound to a null property with a select bound to an undefined property.
<!DOCTYPE html><htmllang="en" ng-app="app"><head><scriptsrc="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script><script>varmodule=angular.module('app',[]);module.controller('AppCtrl',['$scope',function($scope){$scope.defined=null;}]);</script></head><bodyng-controller="AppCtrl"><p>Defined Variable:</p><png-bind="defined"></p><form><selectng-model="defined" name="select-defined" id="select-defined"><optionvalue=""> -- Please Select one --</option><optionvalue="a"> A </option><optionvalue="b"> B </option><optionvalue="c"> C </option></select></form><p>Undefined Variable:</p><png-bind="foo"></p><form><selectng-model="foo" name="select-undefined" id="select-undefined"><optionvalue=""> -- Please Select one --</option><optionvalue="a"> A</option><optionvalue="b"> B</option><optionvalue="c"> C</option></select></form></body></html>
I've tested this with 1.4.0-rc.2 and the problem still exists.
I believe the fix should be to treat null properties the same as undefined.