aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authoranilgulecha2013-09-19 16:08:31 +0530
committerPete Bacon Darwin2013-09-19 12:17:28 +0100
commit910788ed9c5d3132f68e04dadee4b59b3a3a550a (patch)
tree61ba239fc6e6ff6549617c64fc82fbd6cc044095 /docs
parent80ab7eaf150294558405ee124c4aa9c384578b2a (diff)
downloadangular.js-910788ed9c5d3132f68e04dadee4b59b3a3a550a.tar.bz2
docs(guide/services): explain services in plain language
See the discussion at http://docs.angularjs.org/guide/dev_guide.services.understanding_services#comment-1002821035 Closes #4055
Diffstat (limited to 'docs')
-rw-r--r--docs/content/guide/dev_guide.services.understanding_services.ngdoc9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/content/guide/dev_guide.services.understanding_services.ngdoc b/docs/content/guide/dev_guide.services.understanding_services.ngdoc
index 339439a0..fb987c8a 100644
--- a/docs/content/guide/dev_guide.services.understanding_services.ngdoc
+++ b/docs/content/guide/dev_guide.services.understanding_services.ngdoc
@@ -11,6 +11,14 @@ another service) that depends on the service. Angular's dependency injection su
of the rest. The Angular injector subsystem is in charge of service instantiation, resolution of
dependencies, and provision of dependencies to factory functions as requested.
+The purpose of a service factory function is to generate a single object or function that
+represents the service to the rest of the application. That object or function will then be
+passed as a parameter to any other factory function which specifies a dependency on this service.
+
+Angular factory functions are executed lazily. That is, they are only executed when needed
+to satisfy a dependency, and are then executed exactly once for each service. Everything which is
+dependent on this service gets a reference to the single instance generated by the service factory.
+
Angular injects dependencies using "constructor" injection (the service is passed in via a factory
function). Because JavaScript is a dynamically typed language, Angular's dependency injection
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
variables and identifiers, the built-in services always start with `$` (such as `$http` mentioned
above). You can also create your own custom services.
-
## Related Topics
* {@link di About Angular Dependency Injection}