Skip to content

Commit

Permalink
fix(mdAutocomplete): Fix scope watch bug.
Browse files Browse the repository at this point in the history
Commit 8849213 introduced a scope
watching bug cauinsg the autocomplete to no longer update it's list
of items as you scrolled (since it re-uses DOM elements). Fix by
swapping nextTick to be inside the watch statement.

Fixes angular#4713. Closes angular#4715.
  • Loading branch information
topherfangio authored and kennethcachia committed Sep 23, 2015
1 parent c05e952 commit dc2ace3
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function MdAutocompleteItemScopeDirective($compile, $mdUtil) {
};

function postLink(scope, element, attr) {
var ctrl = scope.$mdAutocompleteCtrl;
var ctrl = scope.$mdAutocompleteCtrl;
var newScope = ctrl.parent.$new();
var itemName = ctrl.itemName;

Expand All @@ -32,10 +32,13 @@ function MdAutocompleteItemScopeDirective($compile, $mdUtil) {
* @param variable
* @param alias
*/
function watchVariable (variable, alias) {
$mdUtil.nextTick(function () {
newScope[alias] = scope[variable];
scope.$watch(variable, function (value) { newScope[alias] = value; });
function watchVariable(variable, alias) {
newScope[alias] = scope[variable];

scope.$watch(variable, function(value) {
$mdUtil.nextTick(function() {
newScope[alias] = value;
});
});
}
}
Expand Down

0 comments on commit dc2ace3

Please sign in to comment.