@@ -151,8 +151,9 @@ different currencies and also pay the invoice.
151
151
What changed?
152
152
153
153
First, there is a new JavaScript file that contains a <a name="controller">{@link controller controller}</a>.
154
- More exactly, the file contains a constructor function that creates the actual controller instance.
155
- The purpose of controllers is to expose variables and functionality to expressions and directives.
154
+ More accurately, the file specifies a constructor function that will be used to create the actual
155
+ controller instance. The purpose of controllers is to expose variables and functionality to
156
+ expressions and directives.
156
157
157
158
Besides the new file that contains the controller code we also added an
158
159
{@link ng.directive:ngController `ng-controller`} directive to the HTML.
@@ -251,6 +252,7 @@ Let's refactor our example and move the currency conversion into a service in an
251
252
<img class="pull-right" style="padding-left: 3em; padding-bottom: 1em;" src="img/guide/concepts-module-service.png">
252
253
253
254
What changed?
255
+
254
256
We moved the `convertCurrency` function and the definition of the existing currencies
255
257
into the new file `finance2.js`. But how does the controller
256
258
get a hold of the now separated function?
@@ -274,10 +276,11 @@ The code snippet `angular.module('invoice2', ['finance2'])` specifies that the
274
276
`finance2` module. By this, Angular uses the `InvoiceController` as well as the `currencyConverter` service.
275
277
276
278
Now that Angular knows of all the parts of the application, it needs to create them.
277
- In the previous section we saw that controllers are created using a factory function.
278
- For services there are multiple ways to define their factory
279
+ In the previous section we saw that controllers are created using a constructor function.
280
+ For services, there are multiple ways to specify how they are created
279
281
(see the {@link services service guide}).
280
- In the example above, we are using an anonymous function as the factory function for `currencyConverter` service.
282
+ In the example above, we are using an anonymous function as the factory function for the
283
+ `currencyConverter` service.
281
284
This function should return the `currencyConverter` service instance.
282
285
283
286
Back to the initial question: How does the `InvoiceController` get a reference to the `currencyConverter` function?
0 commit comments