* @ngdoc service * @name $rootScope * @description * * Every application has a single root ng.$rootScope.Scope scope. * All other scopes are descendant scopes of the root scope. Scopes provide separation * between the model and the view, via a mechanism for watching the model for chang
()
| 15493 | * {@link guide/scope developer guide on scopes}. |
| 15494 | */ |
| 15495 | function $RootScopeProvider() { |
| 15496 | var TTL = 10; |
| 15497 | var $rootScopeMinErr = minErr('$rootScope'); |
| 15498 | var lastDirtyWatch = null; |
| 15499 | var applyAsyncId = null; |
| 15500 | |
| 15501 | this.digestTtl = function(value) { |
| 15502 | if (arguments.length) { |
| 15503 | TTL = value; |
| 15504 | } |
| 15505 | return TTL; |
| 15506 | }; |
| 15507 | |
| 15508 | function createChildScopeClass(parent) { |
| 15509 | function ChildScope() { |
| 15510 | this.$$watchers = this.$$nextSibling = |
| 15511 | this.$$childHead = this.$$childTail = null; |
| 15512 | this.$$listeners = {}; |
| 15513 | this.$$listenerCount = {}; |
| 15514 | this.$$watchersCount = 0; |
| 15515 | this.$id = nextUid(); |
| 15516 | this.$$ChildScope = null; |
| 15517 | } |
| 15518 | ChildScope.prototype = parent; |
| 15519 | return ChildScope; |
| 15520 | } |
| 15521 | |
| 15522 | this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', |
| 15523 | function($injector, $exceptionHandler, $parse, $browser) { |
| 15524 | |
| 15525 | function destroyChildScope($event) { |
| 15526 | $event.currentScope.$$destroyed = true; |
| 15527 | } |
| 15528 | |
| 15529 | function cleanUpScope($scope) { |
| 15530 | |
| 15531 | if (msie === 9) { |
| 15532 | // There is a memory leak in IE9 if all child scopes are not disconnected |
| 15533 | // completely when a scope is destroyed. So this code will recurse up through |
| 15534 | // all this scopes children |
| 15535 | // |
| 15536 | // See issue https://github.com/angular/angular.js/issues/10706 |
| 15537 | $scope.$$childHead && cleanUpScope($scope.$$childHead); |
| 15538 | $scope.$$nextSibling && cleanUpScope($scope.$$nextSibling); |
| 15539 | } |
| 15540 | |
| 15541 | // The code below works around IE9 and V8's memory leaks |
| 15542 | // |
| 15543 | // See: |
| 15544 | // - https://code.google.com/p/v8/issues/detail?id=2073#c26 |
| 15545 | // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909 |
| 15546 | // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451 |
| 15547 | |
| 15548 | $scope.$parent = $scope.$$nextSibling = $scope.$$prevSibling = $scope.$$childHead = |
| 15549 | $scope.$$childTail = $scope.$root = $scope.$$watchers = null; |
| 15550 | } |
| 15551 | |
| 15552 | /** |
nothing calls this directly
no test coverage detected