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

Commit 9a27597

Browse files
topherfangioThomasBurleson
authored andcommitted
fix(mdAutocomplete): Fix scope watch bug.
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.
1 parent 4f84137 commit 9a27597

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/autocomplete/js/autocompleteParentScopeDirective.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function MdAutocompleteItemScopeDirective($compile, $mdUtil) {
1010
};
1111

1212
function postLink(scope, element, attr) {
13-
var ctrl = scope.$mdAutocompleteCtrl;
13+
var ctrl = scope.$mdAutocompleteCtrl;
1414
var newScope = ctrl.parent.$new();
1515
var itemName = ctrl.itemName;
1616

@@ -32,10 +32,13 @@ function MdAutocompleteItemScopeDirective($compile, $mdUtil) {
3232
* @param variable
3333
* @param alias
3434
*/
35-
function watchVariable (variable, alias) {
36-
$mdUtil.nextTick(function () {
37-
newScope[alias] = scope[variable];
38-
scope.$watch(variable, function (value) { newScope[alias] = value; });
35+
function watchVariable(variable, alias) {
36+
newScope[alias] = scope[variable];
37+
38+
scope.$watch(variable, function(value) {
39+
$mdUtil.nextTick(function() {
40+
newScope[alias] = value;
41+
});
3942
});
4043
}
4144
}

0 commit comments

Comments
 (0)