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 treats a model viewValue of 0 as the unknown option, resulting in the proper value of the select not being selected #10115

Closed
@hamfastgamgee

Description

@hamfastgamgee

If you define a select using a model with a value of 0, the "unknown option" will get added to the list and the proper selection in the will not be chosen. The problem is this line in self.removeOption: https://github.com/angular/angular.js/blob/master/src/ng/directive/select.js#L215 if (ngModelCtrl.$viewValue == value) { The double-equals check ends up evaluating 0 against the empty string, which succeeds and causes the "unknown option" to be rendered. This needs to be triple-equals, so that 0 really means 0. I strongly suspect that the same should be the case in self.addOption in a similar circumstance. However, I have not found a situation in which the addOption code was problematic (which doesn't mean that none exists). This bug exists minimally in 1.3.3 and 1.2.26.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions