@@ -5,6 +5,13 @@ import {noop} from "./common";
5
5
6
6
/**
7
7
* An interface for getting values from dependency injection.
8
+ *
9
+ * This injector primarily returns resolve values (using a [[ResolveContext]]) that match the given token.
10
+ * If no resolve is found for a token, then it will delegate to the native injector.
11
+ * The native injector may be Angular 1 `$injector`, Angular 2 `Injector`, or a naive polyfill.
12
+ *
13
+ * In Angular 2, the native injector might be the root Injector,
14
+ * or it might be a lazy loaded `NgModule` injector scoped to a lazy load state tree.
8
15
*/
9
16
export interface UIInjector {
10
17
/**
@@ -25,18 +32,17 @@ export interface UIInjector {
25
32
* injector.get(StateService).go('home');
26
33
* ```
27
34
*
28
- * Note:
29
- * The code that implements this interface may be Angular 1 `$injector`, Angular 2 `Injector`,
30
- * a [[ResolveContext]], or a `ResolveContext` that delegates to the ng1/ng2 injector if keys are missing.
31
- *
32
- * @param key the key for the value to get. May be a string or arbitrary object.
33
- * @return the Dependency Injection value that matches the key
35
+ * @param token the key for the value to get. May be a string or arbitrary object.
36
+ * @return the Dependency Injection value that matches the token
34
37
*/
35
- get ( key : any ) : any ;
38
+ get ( token : any ) : any ;
36
39
37
40
/**
38
41
* Asynchronously gets a value from the injector
39
42
*
43
+ * If the [[ResolveContext]] has a [[Resolvable]] matching the token, it will be
44
+ * asynchronously resolved.
45
+ *
40
46
* Returns a promise for a value from the injector.
41
47
* Returns resolve values and/or values from the native injector (ng1/ng2).
42
48
*
@@ -48,8 +54,23 @@ export interface UIInjector {
48
54
* });
49
55
* ```
50
56
*
51
- * @param key the key for the value to get. May be a string or arbitrary object.
52
- * @return a Promise for the Dependency Injection value that matches the key
57
+ * @param token the key for the value to get. May be a string or arbitrary object.
58
+ * @return a Promise for the Dependency Injection value that matches the token
59
+ */
60
+ getAsync ( token : any ) : Promise < any > ;
61
+
62
+ /**
63
+ * Gets a value from the native injector
64
+ *
65
+ * Returns a value from the native injector, bypassing anything in the [[ResolveContext]].
66
+ *
67
+ * Example:
68
+ * ```js
69
+ * let someThing = injector.getNative(SomeToken);
70
+ * ```
71
+ *
72
+ * @param token the key for the value to get. May be a string or arbitrary object.
73
+ * @return the Dependency Injection value that matches the token
53
74
*/
54
- getAsync ( key : any ) : any ;
75
+ getNative ( token : any ) : any ;
55
76
}
0 commit comments