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.

ng-select/ng-options not selecting ng-model if data type number #15296

@GitzJoey

Description

@GitzJoey

Do you want to request a feature or report a bug?
Reporting a bug.

What is the current behavior?
I have a ng-options(with track by) with data type number, and i have a ng-model with data type number.
every time the select/dropdown initialized, the dropdown created not set to the default value of ng-model. Understand this might because the key in option is already converted to string.

some workaround is by removing the track by but it leaves the option value with data type

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).

working sample, how the dropdown 1/select 1 still showing empty while the model value is exist
http://plnkr.co/edit/eCPIjqq9rfoEgGS1Axkl?p=preview

please inspect on select 2 dropdown, the option value has data type in it.

What is the expected behavior?

Since both id having the same data type (number), angular should be able to pick up the ng-model
as default value

What is the motivation / use case for changing the behavior?

i have a legacy system that really hard to change the data type to string, since this behavior changes
in angular, all the drop down unable to select the default value and if i change without track by
i need to change the core system to filter/remove the data type.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Angular 1.5.8

Other information (e.g. stacktraces, related issues, suggestions how to fix)
centOS 7

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions