Fix error switching index patterns in Discover

Needed to cleanup debounced function on scope destory.

Fixes https://github.com/elastic/kibana/issues/9681
This commit is contained in:
Matthew Bargar 2016-12-29 17:29:40 -05:00
parent 5e0ae4c360
commit f82624f7cd

View file

@ -117,11 +117,13 @@ uiModules
}
}
$scope.$watch(debounce(checkWidth, 100));
const debouncedCheckWidth = debounce(checkWidth, 100);
$scope.$watch(debouncedCheckWidth);
// cleanup when the scope is destroyed
$scope.$on('$destroy', function () {
cleanUp();
debouncedCheckWidth.cancel();
$scroller = $window = null;
});
}