diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index c2310a1f11a3..f107a0d95714 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -112,8 +112,24 @@ function $RootScopeProvider() { * compiled HTML template is executed.) * * Here is a simple scope snippet to show how you can interact with the scope. - * ```html - * + * ```js + var scope = $rootScope.$new(); + scope.salutation = 'Hello'; + scope.name = 'World'; + + expect(scope.greeting).toEqual(undefined); + + scope.$watch('name', function() { + scope.greeting = scope.salutation + ' ' + scope.name + '!'; + }); // initialize the watch + + expect(scope.greeting).toEqual(undefined); + scope.name = 'Misko'; + // still old value, since watches have not been called yet + expect(scope.greeting).toEqual(undefined); + + scope.$digest(); // fire all the watches + expect(scope.greeting).toEqual('Hello Misko!'); * ``` * * # Inheritance