forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.injector.html
47 lines (42 loc) · 2.54 KB
/
angular.injector.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<h1>angular.injector</h1>
<div class="angular-injector"><h2>Description</h2>
<div class="description"><p>Creates an inject function that can be used for dependency injection.
(See <a href="#!guide.di">dependency injection</a>)</p>
<p>The inject function can be used for retrieving service instances or for calling any function
which has the $inject property so that the services can be automatically provided. Angular
creates an injection function automatically for the root scope and it is available as
<a href="#!angular.scope.$service"><code>$service</code></a>.</p></div>
<h2>Usage</h2>
<div class="usage"><div ng:non-bindable=""><pre class="brush: js; html-script: true;">angular.injector([providerScope][, providers][, cache]);</pre>
</div>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">providerScope<i>(optional={})</i> – {Object} – </code>
<p>provider's <code>this</code></p></li>
<li><code ng:non-bindable="">providers<i>(optional=angular.service)</i> – {Object.<string, function()>} – </code>
<p>Map of provider (factory)
function.</p></li>
<li><code ng:non-bindable="">cache<i>(optional={})</i> – {Object.<string, function()>} – </code>
<p>Place where instances are saved for reuse. Can
also be used to override services speciafied by <code>providers</code> (useful in tests).</p></li>
</ul>
<h3>Returns</h3>
<div class="returns"><code ng:non-bindable="">{function()}</code>
– <p>Injector function: <code>function(value, scope, args...)</code>:</p>
<ul>
<li><code>value</code> - <code>{string|array|function}</code></li>
<li><code>scope(optional=rootScope)</code> - optional function "<code>this</code>" when <code>value</code> is type <code>function</code>.</li>
<li><code>args(optional)</code> - optional set of arguments to pass to function after injection arguments.
(also known as curry arguments or currying).</li>
</ul>
<h4>Return value of <code>function(value, scope, args...)</code></h4>
<p>The injector function return value depended on the type of <code>value</code> argument:</p>
<ul>
<li><code>string</code>: return an instance for the injection key.</li>
<li><code>array</code> of keys: returns an array of instances for those keys. (see <code>string</code> above.)</li>
<li><code>function</code>: look at <code>$inject</code> property of function to determine instances to inject
and then call the function with instances and <code>scope</code>. Any additional arguments
(<code>args</code>) are appended to the function arguments.</li>
<li><code>none</code>: initialize eager providers.</li>
</ul></div>
</div>
</div>