This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -279,15 +279,20 @@ construction and lookup of dependencies.
279
279
280
280
Here is an example of using the injector service:
281
281
282
+ First create an AngularJS module that will hold the service definition. (The empty array passed as
283
+ the second parameter means that this module does not depend on any other modules.)
284
+
282
285
```js
283
- // Provide the wiring information in a module
286
+ // Create a module to hold the service definition
284
287
var myModule = angular.module('myModule', []);
285
288
```
286
289
287
- Teach the injector how to build a `greeter` service. Notice that `greeter` is dependent on the
288
- `$window` service. The `greeter` service is an object that contains a `greet` method.
290
+ Teach the injector how to build a `greeter` service, which is just an object that contains a `greet`
291
+ method. Notice that `greeter` is dependent on the `$window` service, which will be provided
292
+ (injected into `greeter`) by the injector.
289
293
290
294
```js
295
+ // Define the `greeter` service
291
296
myModule.factory('greeter', function($window) {
292
297
return {
293
298
greet: function(text) {
You can’t perform that action at this time.
0 commit comments