Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bee56a8

Browse files
aevangepetebacondarwin
authored andcommitted
docs(guide/scope): correct scopes example
Remove reference to `employee` property as it's not used in the example. Inject and use `$rootScope` applying `department` property as mentioned in text. Closes #4839
1 parent bcdbfdf commit bee56a8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/content/guide/scope.ngdoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ a diagram depicting the scope boundaries.
126126
</div>
127127
<div ng-controller="ListCtrl">
128128
<ol>
129-
<li ng-repeat="name in names">{{name}}</li>
129+
<li ng-repeat="name in names">{{name}} from {{department}}</li>
130130
</ol>
131131
</div>
132132
</div>
133133
</file>
134134
<file name="script.js">
135-
function GreetCtrl($scope) {
135+
function GreetCtrl($scope, $rootScope) {
136136
$scope.name = 'World';
137+
$rootScope.department = 'Angular';
137138
}
138139

139140
function ListCtrl($scope) {
@@ -153,7 +154,7 @@ a diagram depicting the scope boundaries.
153154

154155
Notice that Angular automatically places `ng-scope` class on elements where scopes are
155156
attached. The `<style>` definition in this example highlights in red the new scope locations. The
156-
child scopes are necessary because the repeater evaluates `{{employee.name}}` expression, but
157+
child scopes are necessary because the repeater evaluates `{{name}}` expression, but
157158
depending on which scope the expression is evaluated it produces different result. Similarly the
158159
evaluation of `{{department}}` prototypically inherits from root scope, as it is the only place
159160
where the `department` property is defined.

0 commit comments

Comments
 (0)