* @ngdoc object * @name ng.$rootScope * @description * * Every application has a single root ng.$rootScope.Scope scope. * All other scopes are child scopes of the root scope. Scopes provide mechanism for watching the model and provide * event processing life-cycle. See {@link guide/sco
()
| 7598 | * event processing life-cycle. See {@link guide/scope developer guide on scopes}. |
| 7599 | */ |
| 7600 | function $RootScopeProvider(){ |
| 7601 | var TTL = 10; |
| 7602 | |
| 7603 | this.digestTtl = function(value) { |
| 7604 | if (arguments.length) { |
| 7605 | TTL = value; |
| 7606 | } |
| 7607 | return TTL; |
| 7608 | }; |
| 7609 | |
| 7610 | this.$get = ['$injector', '$exceptionHandler', '$parse', |
| 7611 | function( $injector, $exceptionHandler, $parse) { |
| 7612 | |
| 7613 | /** |
| 7614 | * @ngdoc function |
| 7615 | * @name ng.$rootScope.Scope |
| 7616 | * |
| 7617 | * @description |
| 7618 | * A root scope can be retrieved using the {@link ng.$rootScope $rootScope} key from the |
| 7619 | * {@link AUTO.$injector $injector}. Child scopes are created using the |
| 7620 | * {@link ng.$rootScope.Scope#$new $new()} method. (Most scopes are created automatically when |
| 7621 | * compiled HTML template is executed.) |
| 7622 | * |
| 7623 | * Here is a simple scope snippet to show how you can interact with the scope. |
| 7624 | * <pre> |
| 7625 | angular.injector(['ng']).invoke(function($rootScope) { |
| 7626 | var scope = $rootScope.$new(); |
| 7627 | scope.salutation = 'Hello'; |
| 7628 | scope.name = 'World'; |
| 7629 | |
| 7630 | expect(scope.greeting).toEqual(undefined); |
| 7631 | |
| 7632 | scope.$watch('name', function() { |
| 7633 | scope.greeting = scope.salutation + ' ' + scope.name + '!'; |
| 7634 | }); // initialize the watch |
| 7635 | |
| 7636 | expect(scope.greeting).toEqual(undefined); |
| 7637 | scope.name = 'Misko'; |
| 7638 | // still old value, since watches have not been called yet |
| 7639 | expect(scope.greeting).toEqual(undefined); |
| 7640 | |
| 7641 | scope.$digest(); // fire all the watches |
| 7642 | expect(scope.greeting).toEqual('Hello Misko!'); |
| 7643 | }); |
| 7644 | * </pre> |
| 7645 | * |
| 7646 | * # Inheritance |
| 7647 | * A scope can inherit from a parent scope, as in this example: |
| 7648 | * <pre> |
| 7649 | var parent = $rootScope; |
| 7650 | var child = parent.$new(); |
| 7651 | |
| 7652 | parent.salutation = "Hello"; |
| 7653 | child.name = "World"; |
| 7654 | expect(child.salutation).toEqual('Hello'); |
| 7655 | |
| 7656 | child.salutation = "Welcome"; |
| 7657 | expect(child.salutation).toEqual('Welcome'); |
nothing calls this directly
no test coverage detected