mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-19 23:11:21 +08:00
refact(select): don't recreate selectedSet on every digest loop
In the case of a "multiple" select, the model value is an array, changes to which don't get picked up by NgModelController as it only looks for object identity change. We were rebuilding the `selectedSet` (a hash map of selected items) from the modelValue on every turn of the digest. This is not needed as we can simply use `$watchCollection` directly on the `$modelValue` instead.
This commit is contained in:
@@ -415,7 +415,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
|
||||
scope.$watchCollection(valuesFn, render);
|
||||
if ( multiple ) {
|
||||
scope.$watchCollection(getSelectedSet, render);
|
||||
scope.$watchCollection(function() { return ctrl.$modelValue; }, render);
|
||||
}
|
||||
|
||||
function getSelectedSet() {
|
||||
|
||||
Reference in New Issue
Block a user