UNPKG

1.62 kBTypeScriptView Raw
1import { $InjectorLike } from '../common/index';
2/**
3 * A basic angular1-like injector api
4 *
5 * This object implements four methods similar to the
6 * [angular 1 dependency injector](https://docs.angularjs.org/api/auto/service/$injector)
7 *
8 * UI-Router evolved from an angular 1 library to a framework agnostic library.
9 * However, some of the `@uirouter/core` code uses these ng1 style APIs to support ng1 style dependency injection.
10 *
11 * This object provides a naive implementation of a globally scoped dependency injection system.
12 * It supports the following DI approaches:
13 *
14 * ### Function parameter names
15 *
16 * A function's `.toString()` is called, and the parameter names are parsed.
17 * This only works when the parameter names aren't "mangled" by a minifier such as UglifyJS.
18 *
19 * ```js
20 * function injectedFunction(FooService, BarService) {
21 * // FooService and BarService are injected
22 * }
23 * ```
24 *
25 * ### Function annotation
26 *
27 * A function may be annotated with an array of dependency names as the `$inject` property.
28 *
29 * ```js
30 * injectedFunction.$inject = [ 'FooService', 'BarService' ];
31 * function injectedFunction(fs, bs) {
32 * // FooService and BarService are injected as fs and bs parameters
33 * }
34 * ```
35 *
36 * ### Array notation
37 *
38 * An array provides the names of the dependencies to inject (as strings).
39 * The function is the last element of the array.
40 *
41 * ```js
42 * [ 'FooService', 'BarService', function (fs, bs) {
43 * // FooService and BarService are injected as fs and bs parameters
44 * }]
45 * ```
46 *
47 * @type {$InjectorLike}
48 */
49export declare const $injector: $InjectorLike;