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

Commit

Permalink
fix(virtualRepeat): Resolve bizarre missing $scope.$root issue (#6129)
Browse files Browse the repository at this point in the history
Closes #6171
  • Loading branch information
kseamon authored and jelbourn committed Dec 9, 2015
1 parent 2f18bb4 commit 190d304
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ var NUM_EXTRA = 3;

/** @ngInject */
function VirtualRepeatContainerController(
$$rAF, $mdUtil, $parse, $window, $scope, $element, $attrs) {
$$rAF, $mdUtil, $parse, $rootScope, $window, $scope, $element, $attrs) {
this.$rootScope = $rootScope;
this.$scope = $scope;
this.$element = $element;
this.$attrs = $attrs;
Expand Down Expand Up @@ -339,7 +340,7 @@ VirtualRepeatContainerController.prototype.handleScroll_ = function() {
if (topIndex !== this.topIndex && topIndex < this.repeater.itemsLength) {
this.topIndex = topIndex;
this.bindTopIndex.assign(this.$scope, topIndex);
if (!this.$scope.$root.$$phase) this.$scope.$digest();
if (!this.$rootScope.$$phase) this.$scope.$digest();
}
}

Expand Down Expand Up @@ -413,12 +414,14 @@ function VirtualRepeatDirective($parse) {


/** @ngInject */
function VirtualRepeatController($scope, $element, $attrs, $browser, $document, $$rAF) {
function VirtualRepeatController($scope, $element, $attrs, $browser, $document, $rootScope,
$$rAF) {
this.$scope = $scope;
this.$element = $element;
this.$attrs = $attrs;
this.$browser = $browser;
this.$document = $document;
this.$rootScope = $rootScope;
this.$$rAF = $$rAF;

/** @type {boolean} Whether we are in on-demand mode. */
Expand Down Expand Up @@ -559,7 +562,7 @@ VirtualRepeatController.prototype.containerUpdated = function() {
this.$$rAF(angular.bind(this, this.readItemSize_));
}
}));
if (!this.$scope.$root.$$phase) this.$scope.$digest();
if (!this.$rootScope.$$phase) this.$scope.$digest();

return;
} else if (!this.sized) {
Expand Down Expand Up @@ -750,7 +753,7 @@ VirtualRepeatController.prototype.updateBlock_ = function(block, index) {
// Perform digest before reattaching the block.
// Any resulting synchronous dom mutations should be much faster as a result.
// This might break some directives, but I'm going to try it for now.
if (!this.$scope.$root.$$phase) {
if (!this.$rootScope.$$phase) {
block.scope.$digest();
}
};
Expand Down

0 comments on commit 190d304

Please sign in to comment.