-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(select): update labels #9061
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,6 +415,18 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { | |
ctrl.$render = render; | ||
|
||
scope.$watchCollection(valuesFn, scheduleRendering); | ||
scope.$watchCollection(function () { | ||
var locals = {}, | ||
values = valuesFn(scope); | ||
if (values) { | ||
var toDisplay = new Array(values.length); | ||
for (var i = 0, ii = values.length; i < ii; i++) { | ||
locals[valueName] = values[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure I'm just not seeing it, but where is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nevermind, apparently was searching for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What this is doing is saying, every digest loop, build a new array of all the display names, which are generated from expressions, which usually rely upon the It is rather heavy weight - if we could say that these expressions only ever depended upon the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the goal here to update labels dynamically though? in which case the values wouldn't matter much. I think we could do a better job by doing the work in a single watcher, but it would be hard to read/reason about (the select directive is already pretty hard to read and reason about) |
||
toDisplay[i] = displayFn(scope, locals); | ||
} | ||
return toDisplay; | ||
} | ||
}, scheduleRendering); | ||
|
||
if (multiple) { | ||
scope.$watchCollection(function() { return ctrl.$modelValue; }, scheduleRendering); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
var values = valuesFn(scope);