MCPcopy
hub / github.com/angular-ui/ui-router / $RootScopeProvider

Function $RootScopeProvider

test/angular/1.7/angular.js:18384–19812  ·  view source on GitHub ↗

* @ngdoc service * @name $rootScope * @this * * @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 mod

()

Source from the content-addressed store, hash-verified

18382 * {@link guide/scope developer guide on scopes}.
18383 */
18384function $RootScopeProvider() {
18385 var TTL = 10;
18386 var $rootScopeMinErr = minErr('$rootScope');
18387 var lastDirtyWatch = null;
18388 var applyAsyncId = null;
18389
18390 this.digestTtl = function(value) {
18391 if (arguments.length) {
18392 TTL = value;
18393 }
18394 return TTL;
18395 };
18396
18397 function createChildScopeClass(parent) {
18398 function ChildScope() {
18399 this.$$watchers = this.$$nextSibling =
18400 this.$$childHead = this.$$childTail = null;
18401 this.$$listeners = {};
18402 this.$$listenerCount = {};
18403 this.$$watchersCount = 0;
18404 this.$id = nextUid();
18405 this.$$ChildScope = null;
18406 this.$$suspended = false;
18407 }
18408 ChildScope.prototype = parent;
18409 return ChildScope;
18410 }
18411
18412 this.$get = ['$exceptionHandler', '$parse', '$browser',
18413 function($exceptionHandler, $parse, $browser) {
18414
18415 function destroyChildScope($event) {
18416 $event.currentScope.$$destroyed = true;
18417 }
18418
18419 function cleanUpScope($scope) {
18420
18421 // Support: IE 9 only
18422 if (msie === 9) {
18423 // There is a memory leak in IE9 if all child scopes are not disconnected
18424 // completely when a scope is destroyed. So this code will recurse up through
18425 // all this scopes children
18426 //
18427 // See issue https://github.com/angular/angular.js/issues/10706
18428 if ($scope.$$childHead) {
18429 cleanUpScope($scope.$$childHead);
18430 }
18431 if ($scope.$$nextSibling) {
18432 cleanUpScope($scope.$$nextSibling);
18433 }
18434 }
18435
18436 // The code below works around IE9 and V8's memory leaks
18437 //
18438 // See:
18439 // - https://code.google.com/p/v8/issues/detail?id=2073#c26
18440 // - https://github.com/angular/angular.js/issues/6794#issuecomment-38648909
18441 // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451

Callers

nothing calls this directly

Calls 15

fnFunction · 0.85
minErrFunction · 0.70
createChildScopeClassFunction · 0.70
$parseFunction · 0.70
isFunctionFunction · 0.70
incrementWatchersCountFunction · 0.70
arrayRemoveFunction · 0.70
listenerFunction · 0.70
forEachFunction · 0.70
beginPhaseFunction · 0.70
flushApplyAsyncFunction · 0.70
equalsFunction · 0.70

Tested by

no test coverage detected