-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
Short description of the problem:
cannot select the appropriate option if its values are objects, but the value tied to ngModel is another object with the same properties.
What behavior are you expecting?
I expect the correct option to be selected when the page loads, despite the fact that they are different objects with the same properties.
Assuming I have the following options tied to my ion-select:
options: any[] = [
{
key: 1,
value: "test 1"
},
{
key: 2,
value: "test 2"
},
{
key: 3,
value: "test 3"
},
];
and I assign the selected option like this:
this.selectedOption = this.options[1];
It will correctly display the option. However, if I assign it like this (creating a new object with the same properties)
this.selectedOption2 = {
key: 3,
value: "test 3"
};
Then the ion-select will be blank
Suggestions:
The option to select is determined by a function that checks for exact equality (or object equality). Perhaps there should be an option that the user can pass in to the ion-select, something like trackBy, that will examine the object values' properties instead of the objects themselves.
Which Ionic Version?
2.x beta 6
Codepen
http://codepen.io/anon/pen/LNweqo
Run ionic info
from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.4.4
Xcode version: Xcode 7.3 Build version 7D175