Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b496daa

Browse files
committed
fix(ngOptions): re-render after empty option has been removed
1 parent 6fc0f02 commit b496daa

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/ng/directive/ngOptions.js

+4
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,12 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
570570
ngModelCtrl.$render();
571571

572572
optionEl.on('$destroy', function() {
573+
var needsRerender = selectCtrl.$isEmptyOptionSelected();
574+
573575
selectCtrl.hasEmptyOption = false;
574576
selectCtrl.emptyOption = undefined;
577+
578+
if (needsRerender) ngModelCtrl.$render();
575579
});
576580
}
577581
};

test/ng/directive/ngOptionsSpec.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -2536,18 +2536,11 @@ describe('ngOptions', function() {
25362536
scope.isBlank = true;
25372537
});
25382538

2539-
expect(element.find('option').length).toBe(2);
2540-
option = element.find('option').eq(0);
2541-
expect(option.val()).toBe('');
2542-
expect(option.text()).toBe('blank');
2539+
expect(element).toEqualSelect([''], 'object:4');
25432540

2544-
scope.$apply(function() {
2545-
scope.isBlank = false;
2546-
});
2541+
scope.$apply('isBlank = false');
25472542

2548-
expect(element.find('option').length).toBe(1);
2549-
option = element.find('option').eq(0);
2550-
expect(option.text()).toBe('A');
2543+
expect(element).toEqualSelect(['?'], 'object:4');
25512544

25522545
scope.$apply('isBlank = true');
25532546

@@ -2571,9 +2564,7 @@ describe('ngOptions', function() {
25712564

25722565
scope.$apply('isBlank = false');
25732566

2574-
options = element.find('option');
2575-
expect(options.length).toBe(1);
2576-
expect(options.eq(0).text()).toBe('A');
2567+
expect(element).toEqualSelect(['?'], 'object:3');
25772568
}
25782569
);
25792570

0 commit comments

Comments
 (0)