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

Commit c0e6527

Browse files
docs(guide/controller): tweak initial example
1 parent be41adc commit c0e6527

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

docs/content/guide/controller.ngdoc

+13-14
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ The properties contain the **view model** (the model that will be presented by t
3737
`$scope` properties will be available to the template at the point in the DOM where the Controller
3838
is registered.
3939

40-
The following example demonstrates setting up
41-
`GreetingController`,
42-
which attaches a `greeting` property containing the string `'Hola!'` to the `$scope`:
43-
44-
We attach the controller as a module on the application using the `.controller` method of your
45-
{@link module Angular Module}. This keeps it out of the global scope.
40+
The following example demonstrates creating a `GreetingController`, which attaches a `greeting`
41+
property containing the string `'Hola!'` to the `$scope`:
4642

4743
```js
4844
var myApp = angular.module('myApp',[]);
@@ -52,9 +48,18 @@ myApp.controller('GreetingController', ['$scope', function($scope) {
5248
}]);
5349
```
5450

51+
We create an {@link module Angular Module}, `myApp`, for our application. Then we add the controller's
52+
constructor function to the module using the `.controller()` method. This keeps the controller's
53+
constructor function out of the global scope.
54+
55+
<div class="alert alert-info">
56+
We have used an **inline injection annotation** to explicitly specify the dependency
57+
of the Controller on the `$scope` service provided by Angular. See the guide on
58+
{@link guide/di Dependency Injection} for more information.
59+
</div>
5560

56-
Once the Controller has been attached to the DOM, the `greeting` property can be data-bound to the
57-
template:
61+
We attach our controller to the DOM using the `ng-controller` directive. The `greeting` property can
62+
now be data-bound to the template:
5863

5964
```js
6065
<div ng-controller="GreetingController">
@@ -63,12 +68,6 @@ template:
6368
```
6469

6570

66-
67-
We have used an **inline injection annotation** to explicitly specify the dependency
68-
of the Controller on the `$scope` service provided by Angular. See the guide on
69-
[Dependency Injection](http://docs.angularjs.org/guide/di) for more information.
70-
71-
7271
# Adding Behavior to a Scope Object
7372

7473
In order to react to events or execute computation in the view we must provide behavior to the

0 commit comments

Comments
 (0)