@@ -37,12 +37,8 @@ The properties contain the **view model** (the model that will be presented by t
37
37
`$scope` properties will be available to the template at the point in the DOM where the Controller
38
38
is registered.
39
39
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`:
46
42
47
43
```js
48
44
var myApp = angular.module('myApp',[]);
@@ -52,9 +48,18 @@ myApp.controller('GreetingController', ['$scope', function($scope) {
52
48
}]);
53
49
```
54
50
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>
55
60
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:
58
63
59
64
```js
60
65
<div ng-controller="GreetingController">
@@ -63,12 +68,6 @@ template:
63
68
```
64
69
65
70
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
-
72
71
# Adding Behavior to a Scope Object
73
72
74
73
In order to react to events or execute computation in the view we must provide behavior to the
0 commit comments