|
2 | 2 | @name Developer Guide: Angular Services: Creating Services |
3 | 3 | @description |
4 | 4 |
|
5 | | -While angular offers several useful services, for any nontrivial application you'll find it useful |
| 5 | +While Angular offers several useful services, for any nontrivial application you'll find it useful |
6 | 6 | to write your own custom services. To do this you begin by registering a service factory function |
7 | 7 | with a module either via the {@link api/angular.module Module#factory api} or directly |
8 | 8 | via the {@link api/AUTO.$provide $provide} api inside of module config function. |
9 | 9 |
|
10 | | -All angular services participate in {@link di dependency injection (DI)} by registering |
| 10 | +All Angular services participate in {@link di dependency injection (DI)} by registering |
11 | 11 | themselves with Angular's DI system (injector) under a `name` (id) as well as by declaring |
12 | 12 | dependencies which need to be provided for the factory function of the registered service. The |
13 | 13 | ability to swap dependencies for mocks/stubs/dummies in tests allows for services to be highly |
@@ -76,17 +76,17 @@ angular.module('myModule', [], function($provide) { |
76 | 76 |
|
77 | 77 | # Instantiating Angular Services |
78 | 78 |
|
79 | | -All services in Angular are instantiates services lazily, this means that a service will be created |
| 79 | +All services in Angular are instantiated lazily. This means that a service will be created |
80 | 80 | only when it is needed for instantiation of a service or an application component that depends on it. |
81 | | -In other words, angular won't instantiate lazy services unless they are requested directly or |
| 81 | +In other words, Angular won't instantiate lazy services unless they are requested directly or |
82 | 82 | indirectly by the application. |
83 | 83 |
|
84 | 84 |
|
85 | 85 | # Services as singletons |
86 | 86 |
|
87 | | -Lastly, it is important to realize that all angular services are application singletons. This means |
88 | | -that there is only one instance of a given service per injector. Since angular is lethally allergic |
89 | | -to the global state, it is possible to create multiple injectors, each with its own instance of a |
| 87 | +Lastly, it is important to realize that all Angular services are application singletons. This means |
| 88 | +that there is only one instance of a given service per injector. Since Angular is lethally allergic |
| 89 | +to global state, it is possible to create multiple injectors, each with its own instance of a |
90 | 90 | given service, but that is rarely needed, except in tests where this property is crucially |
91 | 91 | important. |
92 | 92 |
|
|
0 commit comments