* @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
()
| 11931 | * {@link guide/scope developer guide on scopes}. |
| 11932 | */ |
| 11933 | function $RootScopeProvider(){ |
| 11934 | var TTL = 10; |
| 11935 | var $rootScopeMinErr = minErr('$rootScope'); |
| 11936 | var lastDirtyWatch = null; |
| 11937 | |
| 11938 | this.digestTtl = function(value) { |
| 11939 | if (arguments.length) { |
| 11940 | TTL = value; |
| 11941 | } |
| 11942 | return TTL; |
| 11943 | }; |
| 11944 | |
| 11945 | this.$get = ['$injector', '$exceptionHandler', '$parse', '$browser', |
| 11946 | function( $injector, $exceptionHandler, $parse, $browser) { |
| 11947 | |
| 11948 | /** |
| 11949 | * @ngdoc type |
| 11950 | * @name $rootScope.Scope |
| 11951 | * |
| 11952 | * @description |
| 11953 | * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the |
| 11954 | * {@link auto.$injector $injector}. Child scopes are created using the |
| 11955 | * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when |
| 11956 | * compiled HTML template is executed.) |
| 11957 | * |
| 11958 | * Here is a simple scope snippet to show how you can interact with the scope. |
| 11959 | * ```html |
| 11960 | * <file src="./test/ng/rootScopeSpec.js" tag="docs1" /> |
| 11961 | * ``` |
| 11962 | * |
| 11963 | * # Inheritance |
| 11964 | * A scope can inherit from a parent scope, as in this example: |
| 11965 | * ```js |
| 11966 | var parent = $rootScope; |
| 11967 | var child = parent.$new(); |
| 11968 | |
| 11969 | parent.salutation = "Hello"; |
| 11970 | child.name = "World"; |
| 11971 | expect(child.salutation).toEqual('Hello'); |
| 11972 | |
| 11973 | child.salutation = "Welcome"; |
| 11974 | expect(child.salutation).toEqual('Welcome'); |
| 11975 | expect(parent.salutation).toEqual('Hello'); |
| 11976 | * ``` |
| 11977 | * |
| 11978 | * |
| 11979 | * @param {Object.<string, function()>=} providers Map of service factory which need to be |
| 11980 | * provided for the current scope. Defaults to {@link ng}. |
| 11981 | * @param {Object.<string, *>=} instanceCache Provides pre-instantiated services which should |
| 11982 | * append/override services provided by `providers`. This is handy |
| 11983 | * when unit-testing and having the need to override a default |
| 11984 | * service. |
| 11985 | * @returns {Object} Newly created scope. |
| 11986 | * |
| 11987 | */ |
| 11988 | function Scope() { |
| 11989 | this.$id = nextUid(); |
| 11990 | this.$$phase = this.$parent = this.$$watchers = |
nothing calls this directly
no test coverage detected