doc(guide/controller): fix examples

This commit is contained in:
Igor Minar 2012-03-23 16:54:48 -07:00
parent 2be8847ef6
commit 4581b79bbd

View file

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