mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-22 10:49:24 +08:00
fix(select): make ctrl.hasOption method consistent
Prior to this fix, options added to a select by ngOptions would not cause `selectCtrl.hasOption` to return `true` Closes #8761
This commit is contained in:
@@ -611,6 +611,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
id: option.id,
|
||||
selected: option.selected
|
||||
});
|
||||
selectCtrl.addOption(option.label, element);
|
||||
if (lastElement) {
|
||||
lastElement.after(element);
|
||||
} else {
|
||||
@@ -622,7 +623,9 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
// remove any excessive OPTIONs in a group
|
||||
index++; // increment since the existingOptions[0] is parent element not OPTION
|
||||
while(existingOptions.length > index) {
|
||||
existingOptions.pop().element.remove();
|
||||
option = existingOptions.pop();
|
||||
selectCtrl.removeOption(option.label);
|
||||
option.element.remove();
|
||||
}
|
||||
}
|
||||
// remove any excessive OPTGROUPs from select
|
||||
|
||||
Reference in New Issue
Block a user