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:
Peter Bacon Darwin
2014-07-31 07:13:55 +01:00
parent d2f8f25af2
commit 9a2f8e1778

View File

@@ -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() {