This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,14 @@ another service) that depends on the service. Angular's dependency injection su
11
11
of the rest. The Angular injector subsystem is in charge of service instantiation, resolution of
12
12
dependencies, and provision of dependencies to factory functions as requested.
13
13
14
+ The purpose of a service factory function is to generate a single object or function that
15
+ represents the service to the rest of the application. That object or function will then be
16
+ passed as a parameter to any other factory function which specifies a dependency on this service.
17
+
18
+ Angular factory functions are executed lazily. That is, they are only executed when needed
19
+ to satisfy a dependency, and are then executed exactly once for each service. Everything which is
20
+ dependent on this service gets a reference to the single instance generated by the service factory.
21
+
14
22
Angular injects dependencies using "constructor" injection (the service is passed in via a factory
15
23
function). Because JavaScript is a dynamically typed language, Angular's dependency injection
16
24
subsystem cannot use static types to identify service dependencies. For this reason a dependent
@@ -22,7 +30,6 @@ The Angular web framework provides a set of services for common operations. Like
22
30
variables and identifiers, the built-in services always start with `$` (such as `$http` mentioned
23
31
above). You can also create your own custom services.
24
32
25
-
26
33
## Related Topics
27
34
28
35
* {@link di About Angular Dependency Injection}
You can’t perform that action at this time.
0 commit comments