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

Commit 7f82986

Browse files
fix(ngOptions): use watchCollection not deep watch of ngModel
1 parent 74eb17d commit 7f82986

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/ng/directive/ngOptions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
515515
// We also need to watch to see if the internals of the model changes, since
516516
// ngModel only watches for object identity change
517517
if (ngOptions.trackBy) {
518-
scope.$watch(attr.ngModel, function() { ngModelCtrl.$render(); }, true);
518+
scope.$watchCollection(attr.ngModel, function() { ngModelCtrl.$render(); });
519519
}
520520
// ------------------------------------------------------------------ //
521521

test/ng/directive/ngOptionsSpec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,7 @@ describe('ngOptions', function() {
901901

902902
// Update the properties on the object in the selected array, rather than replacing the whole object
903903
scope.$apply(function() {
904-
scope.selected[0].id = 20;
905-
scope.selected[0].label = 'new twenty';
904+
scope.selected[0] = {id: 20, label: 'new twenty'};
906905
});
907906

908907
// The value of the select should change since the id property changed

0 commit comments

Comments
 (0)