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

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 #4713. Closes #4715.
  • Loading branch information
topherfangio authored and ThomasBurleson committed Sep 22, 2015
1 parent 4f84137 commit 9a27597
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 9a27597

Please sign in to comment.