@@ -6,18 +6,17 @@ The most common place to use dependency injection in angular applications is in
6
6
dev_guide.mvc.understanding_controller controllers}. Here is a simple example:
7
7
8
8
<pre>
9
- function MyController($route){
10
- // configure the route service
11
- $route.when(...);
9
+ function MyController($location){
10
+ // do stuff with the $location service
12
11
}
13
- MyController.$inject = ['$route '];
12
+ MyController.$inject = ['$location '];
14
13
</pre>
15
14
16
15
In this example, the `MyController` constructor function takes one argument, the {@link
17
- api/angular.module.ng.$route $route } service. Angular is then responsible for supplying the instance
18
- of `$route ` to the controller when the constructor is instantiated. There are two ways to cause
19
- controller instantiation – by configuring routes with the `$route ` service, or by referencing the
20
- controller from the HTML template, as follows:
16
+ api/angular.module.ng.$location $location } service. Angular is then responsible for supplying the
17
+ instance of `$location ` to the controller when the constructor is instantiated. There are two ways
18
+ to cause controller instantiation – by configuring routes with the `$location ` service, or by
19
+ referencing the controller from the HTML template, as follows:
21
20
22
21
<pre>
23
22
<!doctype html>
@@ -35,7 +34,7 @@ we have to supply this information to angular in the form of an additional prope
35
34
controller constructor function called `$inject`. Think of it as annotations for JavaScript.
36
35
37
36
<pre>
38
- MyController.$inject = ['$route '];
37
+ MyController.$inject = ['$location '];
39
38
</pre>
40
39
41
40
The information in `$inject` is then used by the {@link api/angular.injector injector} to call the
0 commit comments