aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/dev_guide.services.managing_dependencies.ngdoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/guide/dev_guide.services.managing_dependencies.ngdoc')
-rw-r--r--docs/content/guide/dev_guide.services.managing_dependencies.ngdoc14
1 files changed, 0 insertions, 14 deletions
diff --git a/docs/content/guide/dev_guide.services.managing_dependencies.ngdoc b/docs/content/guide/dev_guide.services.managing_dependencies.ngdoc
index 5adbefae..5f45b001 100644
--- a/docs/content/guide/dev_guide.services.managing_dependencies.ngdoc
+++ b/docs/content/guide/dev_guide.services.managing_dependencies.ngdoc
@@ -3,20 +3,16 @@
@name Developer Guide: Angular Services: Managing Service Dependencies
@description
-
Angular allows services to declare other services as dependencies needed for construction of their
instances.
-
To declare dependencies, you specify them in the factory function signature and via the `$inject`
property, as an array of string identifiers. Optionally the `$inject` property declaration can be
dropped (see "Inferring `$inject`" but note that that is currently an experimental feature).
-
Here is an example of two services that depend on each other, as well as on other services that are
provided by angular's web framework:
-
<pre>
/**
* batchLog service allows for messages to be queued in memory and flushed
@@ -27,7 +23,6 @@ provided by angular's web framework:
angular.service('batchLog', function($defer, $log) {
var messageQueue = [];
-
function log() {
if (messageQueue.length) {
$log('batchLog messages: ', messageQueue);
@@ -36,14 +31,12 @@ function log() {
$defer(log, 50000);
}
-
return function(message) {
messageQueue.push(message);
}
}, {$inject: ['$defer', '$log']);
// note how we declared dependency on built-in $defer and $log services above
-
/**
* routeTemplateMonitor monitors each $route change and logs the current
* template via the batchLog service.
@@ -55,10 +48,8 @@ $route.onChange(function() {
}, {$inject: ['$route', 'batchLog'], $eager: true});
</pre>
-
Things to notice in this example:
-
* The `batchLog` service depends on the built-in {@link api/angular.service.$defer $defer} and
{@link api/angular.service.$log $log} services, and allows messages to be logged into the
`console.log` in batches.
@@ -77,20 +68,15 @@ this array with IDs and their order that the injector uses to determine which se
order to inject.
-
-
## Related Topics
-
* {@link dev_guide.services.understanding_services Understanding Angular Services}
* {@link dev_guide.services.creating_services Creating Angular Services}
* {@link dev_guide.services.registering_services Registering Services}
* {@link dev_guide.services.injecting_controllers Injecting Services Into Controllers }
* {@link dev_guide.services.testing_services Testing Angular Services}
-
## Related API
-
* {@link api/angular.service Angular Service API}
* {@link api/angular.injector Angular Injector API}