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.

Adding ng-model to predefined Select element adds undefined option #1019

@OuchMyHead

Description

@OuchMyHead

Adding ng-model:"foo" to a prepopulated select element results in an additional "undefined" option being added and removes the effect of select:"select".

The HTML:

<select ng-model="foo" ng-app >
    <option value="1">1</option>
    <option selected="selected" value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
</select>

Becomes:

<select ng-model="foo" ng-app >
    <option value="? undefined:undefined ?"></option>
    <option value="1">1</option>
    <option selected="selected" value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
</select>

In the example above the first option value="? undefined:undefined ?" is selected instead of the expected option value="2".

Reproduced at http://jsfiddle.net/K8rSu/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions