* @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
()
| 14970 | * {@link guide/scope developer guide on scopes}. |
| 14971 | */ |
| 14972 | function $RootScopeProvider() { |
| 14973 | var TTL = 10; |
| 14974 | var $rootScopeMinErr = minErr('$rootScope'); |
| 14975 | var lastDirtyWatch = null; |
| 14976 | var applyAsyncId = null; |
| 14977 | |
| 14978 | this.digestTtl = function(value) { |
| 14979 | if (arguments.length) { |
| 14980 | TTL = value; |
| 14981 | } |
| 14982 | return TTL; |
| 14983 | }; |
| 14984 | |
| 14985 | function createChildScopeClass(parent) { |
| 14986 | function ChildScope() { |
| 14987 | this.$$watchers = this.$$nextSibling = |
| 14988 | this.$$childHead = this.$$childTail = null; |
| 14989 | this.$$listeners = {}; |
| 14990 | this.$$listenerCount = {}; |
| 14991 | this.$$watchersCount = 0; |
| 14992 | this.$id = nextUid(); |
| 14993 | this.$$ChildScope = null; |
| 14994 | } |
| 14995 | ChildScope.prototype = parent; |
| 14996 | return ChildScope; |
| 14997 | } |
| 14998 | |
| 14999 | this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', |
| 15000 | function($injector, $exceptionHandler, $parse, $browser) { |
| 15001 | |
| 15002 | function destroyChildScope($event) { |
| 15003 | $event.currentScope.$$destroyed = true; |
| 15004 | } |
| 15005 | |
| 15006 | /** |
| 15007 | * @ngdoc type |
| 15008 | * @name $rootScope.Scope |
| 15009 | * |
| 15010 | * @description |
| 15011 | * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the |
| 15012 | * {@link auto.$injector $injector}. Child scopes are created using the |
| 15013 | * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when |
| 15014 | * compiled HTML template is executed.) |
| 15015 | * |
| 15016 | * Here is a simple scope snippet to show how you can interact with the scope. |
| 15017 | * ```html |
| 15018 | * <file src="./test/ng/rootScopeSpec.js" tag="docs1" /> |
| 15019 | * ``` |
| 15020 | * |
| 15021 | * # Inheritance |
| 15022 | * A scope can inherit from a parent scope, as in this example: |
| 15023 | * ```js |
| 15024 | var parent = $rootScope; |
| 15025 | var child = parent.$new(); |
| 15026 | |
| 15027 | parent.salutation = "Hello"; |
| 15028 | expect(child.salutation).toEqual('Hello'); |
| 15029 |
nothing calls this directly
no test coverage detected