* @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
()
| 12105 | * {@link guide/scope developer guide on scopes}. |
| 12106 | */ |
| 12107 | function $RootScopeProvider(){ |
| 12108 | var TTL = 10; |
| 12109 | var $rootScopeMinErr = minErr('$rootScope'); |
| 12110 | var lastDirtyWatch = null; |
| 12111 | |
| 12112 | this.digestTtl = function(value) { |
| 12113 | if (arguments.length) { |
| 12114 | TTL = value; |
| 12115 | } |
| 12116 | return TTL; |
| 12117 | }; |
| 12118 | |
| 12119 | this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', |
| 12120 | function( $injector, $exceptionHandler, $parse, $browser) { |
| 12121 | |
| 12122 | /** |
| 12123 | * @ngdoc type |
| 12124 | * @name $rootScope.Scope |
| 12125 | * |
| 12126 | * @description |
| 12127 | * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the |
| 12128 | * {@link auto.$injector $injector}. Child scopes are created using the |
| 12129 | * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when |
| 12130 | * compiled HTML template is executed.) |
| 12131 | * |
| 12132 | * Here is a simple scope snippet to show how you can interact with the scope. |
| 12133 | * ```html |
| 12134 | * <file src="./test/ng/rootScopeSpec.js" tag="docs1" /> |
| 12135 | * ``` |
| 12136 | * |
| 12137 | * # Inheritance |
| 12138 | * A scope can inherit from a parent scope, as in this example: |
| 12139 | * ```js |
| 12140 | var parent = $rootScope; |
| 12141 | var child = parent.$new(); |
| 12142 | |
| 12143 | parent.salutation = "Hello"; |
| 12144 | child.name = "World"; |
| 12145 | expect(child.salutation).toEqual('Hello'); |
| 12146 | |
| 12147 | child.salutation = "Welcome"; |
| 12148 | expect(child.salutation).toEqual('Welcome'); |
| 12149 | expect(parent.salutation).toEqual('Hello'); |
| 12150 | * ``` |
| 12151 | * |
| 12152 | * |
| 12153 | * @param {Object.<string, function()>=} providers Map of service factory which need to be |
| 12154 | * provided for the current scope. Defaults to {@link ng}. |
| 12155 | * @param {Object.<string, *>=} instanceCache Provides pre-instantiated services which should |
| 12156 | * append/override services provided by `providers`. This is handy |
| 12157 | * when unit-testing and having the need to override a default |
| 12158 | * service. |
| 12159 | * @returns {Object} Newly created scope. |
| 12160 | * |
| 12161 | */ |
| 12162 | function Scope() { |
| 12163 | this.$id = nextUid(); |
| 12164 | this.$$phase = this.$parent = this.$$watchers = |
nothing calls this directly
no test coverage detected