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:
Brian Ford
2014-09-24 15:33:35 -07:00
parent b0033a44bd
commit 2bcd02dc1a
2 changed files with 70 additions and 1 deletions

View File

@@ -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