Skip to content

Commit dc2ace3

Browse files
topherfangiokennethcachia
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 angular#4713. Closes angular#4715.
1 parent c05e952 commit dc2ace3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/autocomplete/js/autocompleteParentScopeDirective.js

+8-5
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)