You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
So, context:
I have objects with an field 'id' (a string).
I list those objects in a ngSelect directive with ng-option. I use the field 'id' as label, and the object itself as value (I use ng-model to retrieve this value in the controller).
Those objects implement a toString method that simply return the field 'id'.
Nothing is initially selected in the ngSelect.
Problem: when I try to select an object using the ngSelect from the interface, it is (visually) unselected right away.
Expected cause: in the function removeOption (I suspect there is the same issue in addOption)
self.removeOption = function(value) {
if (this.hasOption(value)) {
delete optionsMap[value];
if (ngModelCtrl.$viewValue == value) {
this.renderUnknownOption(value);
}
}
};
The condition ngModelCtrl.$viewValue == value evaluates to true (this non-strict comparison uses the toString method of the object stored in $viewValue, which unfortunately for me, evaluates to the same value as the label).
Thanks in advance for your time.
[edit]
Actually, could not reproduce the bug in a jsfiddle for demo... Will try to see what went wrong.
[edit 2]
Ok, the bug is present in 1.3.0-rc4 but not in 1.2.1 apparently.
@joelross - Thanks for posting this. This is indeed a regression that was introduced in rc4. It is described in a bit more detail in #9418 and there is a pending PR #9421 with a fix. I'm going to close this as duplicate, but feel free to reopen if you think that this issue is something different.
Hello,
So, context:
I have objects with an field 'id' (a string).
I list those objects in a ngSelect directive with ng-option. I use the field 'id' as label, and the object itself as value (I use ng-model to retrieve this value in the controller).
Those objects implement a toString method that simply return the field 'id'.
Nothing is initially selected in the ngSelect.
Problem: when I try to select an object using the ngSelect from the interface, it is (visually) unselected right away.
Expected cause: in the function removeOption (I suspect there is the same issue in addOption)
The condition
ngModelCtrl.$viewValue == value
evaluates to true (this non-strict comparison uses the toString method of the object stored in $viewValue, which unfortunately for me, evaluates to the same value as the label).Thanks in advance for your time.
[edit]
Actually, could not reproduce the bug in a jsfiddle for demo... Will try to see what went wrong.
[edit 2]
Ok, the bug is present in 1.3.0-rc4 but not in 1.2.1 apparently.
correct behaviour, without toString
faulty behaviour, with toString
(try to select the value and see what happen to the select)
The text was updated successfully, but these errors were encountered: