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

Commit

Permalink
perf(ngOptions): only watch labels if a display expression is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Feb 13, 2015
1 parent 3c6a0e5 commit 51faaff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ng/directive/ngOptions.js
Expand Up @@ -267,10 +267,14 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {

Object.keys(values).forEach(function getWatchable(key) {
var locals = getLocals(values[key], key);
var label = displayFn(scope, locals);
var selectValue = getTrackByValue(values[key], locals);
watchedArray.push(selectValue);
watchedArray.push(label);

// Only need to watch the displayFn if there is a specific label expression
if (match[2]) {
var label = displayFn(scope, locals);
watchedArray.push(label);
}
});
return watchedArray;
}),
Expand Down

1 comment on commit 51faaff

@petebacondarwin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #11052

Please sign in to comment.