diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 89279608464c..d4c49e8f9b63 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -764,7 +764,7 @@ function $RootScopeProvider() { var watch, value, last, fn, get, watchers, dirty, ttl = TTL, - next, current, target = this, + next, current, target = asyncQueue.length ? $rootScope : this, watchLog = [], logIdx, asyncTask; diff --git a/test/ng/rootScopeSpec.js b/test/ng/rootScopeSpec.js index 93f3dc9e6eef..26fc5473bdde 100644 --- a/test/ng/rootScopeSpec.js +++ b/test/ng/rootScopeSpec.js @@ -1498,6 +1498,25 @@ describe('Scope', function() { $browser.defer.flush(100000); expect(log).toEqual(['eval-ed 1!', 'eval-ed 2!']); }); + + it('should not have execution affected by an explicit $digest call', function() { + var scope1 = $rootScope.$new(); + var scope2 = $rootScope.$new(); + + scope1.$watch('value', function(value) { + scope1.result = value; + }); + + scope1.$evalAsync(function() { + scope1.value = 'bar'; + }); + + scope2.$digest(); + + $browser.defer.flush(0); + + expect(scope1.result).toBe('bar'); + }); }); });