This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ngOptions.js throws type error when selecting empty value and using 'multiple' on select #12511
Closed
Description
When selecting the empty value <option value=""></option>
on a <select multiple="multiple" ng-options="v.label for(k,v) in options">
a type error is thrown.
OS/Browser: All
Version: Angular 1.4.3
Fiddle: https://jsfiddle.net/HB7LU/16138/
Code:
angular.js/src/ng/directive/ngOptions.js
Line 529 in 14638f4
Stack Trace:
TypeError: Cannot read property 'disabled' of undefined
at angular.min.js:272
at m (angular.min.js:7)
at u.readValue (angular.min.js:272)
at angular.min.js:285
at n.$eval (angular.min.js:134)
at n.$apply (angular.min.js:135)
at HTMLSelectElement.<anonymous> (angular.min.js:285)
at HTMLSelectElement.Gf.c (angular.min.js:35)
Fix:
Replace
if (!option.disabled) selections.push(options.getViewValueFromOption(option));
with
if (option && !option.disabled) selections.push(options.getViewValueFromOption(option));
same as in Line 517.