From 64a7ae4a4ca1e455937769387d46754f7fa502f8 Mon Sep 17 00:00:00 2001 From: louisik1 Date: Fri, 19 Jun 2015 00:37:56 -0700 Subject: [PATCH 1/2] docs($rootScope.Scope): reinsert lost example This doc example was lost long ago here https://github.com/angular/angular.js/commit/2845dd159087fc59eb29845a578f32c7c462e8e6 As it is now, it says 'here is a simple scope snippet...' but has a non-linking file link to the test doc. Doesn't make sense. This change simply puts back the example as it originally was. --- src/ng/rootScope.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index c2310a1f11a3..d0785fe055e2 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 From 2a67fd8b66548d5127e8b157acdd9d51be33d526 Mon Sep 17 00:00:00 2001 From: louisik1 Date: Fri, 19 Jun 2015 10:10:47 -0700 Subject: [PATCH 2/2] Update rootScope.js removed extra white space at line 131 per code review suggestion --- src/ng/rootScope.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index d0785fe055e2..f107a0d95714 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -128,7 +128,7 @@ function $RootScopeProvider() { // still old value, since watches have not been called yet expect(scope.greeting).toEqual(undefined); - scope.$digest(); // fire all the watches + scope.$digest(); // fire all the watches expect(scope.greeting).toEqual('Hello Misko!'); * ``` *