Skip to content
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
@arm1n

Description

@arm1n

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:

if (!option.disabled) selections.push(options.getViewValueFromOption(option));

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions