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
This commit is contained in:
andre 2013-11-08 10:43:40 -08:00 committed by Pete Bacon Darwin
parent bcdbfdfeae
commit bee56a82b0

View file

@ -126,14 +126,15 @@ a diagram depicting the scope boundaries.
</div>
<div ng-controller="ListCtrl">
<ol>
<li ng-repeat="name in names">{{name}}</li>
<li ng-repeat="name in names">{{name}} from {{department}}</li>
</ol>
</div>
</div>
</file>
<file name="script.js">
function GreetCtrl($scope) {
function GreetCtrl($scope, $rootScope) {
$scope.name = 'World';
$rootScope.department = 'Angular';
}
function ListCtrl($scope) {
@ -153,7 +154,7 @@ a diagram depicting the scope boundaries.
Notice that Angular automatically places `ng-scope` class on elements where scopes are
attached. The `<style>` definition in this example highlights in red the new scope locations. The
child scopes are necessary because the repeater evaluates `{{employee.name}}` expression, but
child scopes are necessary because the repeater evaluates `{{name}}` expression, but
depending on which scope the expression is evaluated it produces different result. Similarly the
evaluation of `{{department}}` prototypically inherits from root scope, as it is the only place
where the `department` property is defined.