6
6
* - [quick start repository](http://github.com/ui-router/quickstart-ng2)
7
7
*
8
8
* Getting started:
9
- *
9
+ *
10
10
* - Use npm. Add a dependency on latest `ui-router-ng2`
11
11
* - Import UI-Router classes directly from `"ui-router-ng2"`
12
12
*
@@ -111,9 +111,7 @@ import {NATIVE_INJECTOR_TOKEN} from "ui-router-core";
111
111
* Creates a UIRouter instance and configures it for Angular 2, then invokes router bootstrap.
112
112
* This function is used as an Angular 2 `useFactory` Provider.
113
113
*/
114
- let uiRouterFactory = (
115
- location : UIRouterLocation ,
116
- injector : Injector ) => {
114
+ export function uiRouterFactory ( location : UIRouterLocation , injector : Injector ) {
117
115
118
116
let rootModules : RootModule [ ] = injector . get ( UIROUTER_ROOT_MODULE ) ;
119
117
let modules : StatesModule [ ] = injector . get ( UIROUTER_MODULE_TOKEN ) ;
@@ -167,20 +165,30 @@ let uiRouterFactory = (
167
165
return router ;
168
166
} ;
169
167
168
+ export function parentUIViewInjectFactory ( r : StateRegistry ) { return { fqn : null , context : r . root ( ) } as ParentUIViewInject ; }
169
+
170
170
export const _UIROUTER_INSTANCE_PROVIDERS : Provider [ ] = [
171
171
{ provide : UIRouter , useFactory : uiRouterFactory , deps : [ UIRouterLocation , Injector ] } ,
172
172
{ provide : UIRouterLocation , useClass : UIRouterLocation } ,
173
- { provide : UIView . PARENT_INJECT , useFactory : ( r : StateRegistry ) => { return { fqn : null , context : r . root ( ) } as ParentUIViewInject } , deps : [ StateRegistry ] } ,
173
+ { provide : UIView . PARENT_INJECT , useFactory : parentUIViewInjectFactory , deps : [ StateRegistry ] } ,
174
174
] ;
175
175
176
+ export function fnStateService ( r : UIRouter ) { return r . stateService ; }
177
+ export function fnTransitionService ( r : UIRouter ) { return r . transitionService ; }
178
+ export function fnUrlMatcherFactory ( r : UIRouter ) { return r . urlMatcherFactory ; }
179
+ export function fnUrlRouter ( r : UIRouter ) { return r . urlRouter ; }
180
+ export function fnViewService ( r : UIRouter ) { return r . viewService ; }
181
+ export function fnStateRegistry ( r : UIRouter ) { return r . stateRegistry ; }
182
+ export function fnGlobals ( r : any ) { return r . globals ; }
183
+
176
184
export const _UIROUTER_SERVICE_PROVIDERS : Provider [ ] = [
177
- { provide : StateService , useFactory : ( r : UIRouter ) => r . stateService , deps : [ UIRouter ] } ,
178
- { provide : TransitionService , useFactory : ( r : UIRouter ) => r . transitionService , deps : [ UIRouter ] } ,
179
- { provide : UrlMatcherFactory , useFactory : ( r : UIRouter ) => r . urlMatcherFactory , deps : [ UIRouter ] } ,
180
- { provide : UrlRouter , useFactory : ( r : UIRouter ) => r . urlRouter , deps : [ UIRouter ] } ,
181
- { provide : ViewService , useFactory : ( r : UIRouter ) => r . viewService , deps : [ UIRouter ] } ,
182
- { provide : StateRegistry , useFactory : ( r : UIRouter ) => r . stateRegistry , deps : [ UIRouter ] } ,
183
- { provide : Globals , useFactory : ( r : UIRouter ) => r . globals , deps : [ UIRouter ] } ,
185
+ { provide : StateService , useFactory : fnStateService , deps : [ UIRouter ] } ,
186
+ { provide : TransitionService , useFactory : fnTransitionService , deps : [ UIRouter ] } ,
187
+ { provide : UrlMatcherFactory , useFactory : fnUrlMatcherFactory , deps : [ UIRouter ] } ,
188
+ { provide : UrlRouter , useFactory : fnUrlRouter , deps : [ UIRouter ] } ,
189
+ { provide : ViewService , useFactory : fnViewService , deps : [ UIRouter ] } ,
190
+ { provide : StateRegistry , useFactory : fnStateRegistry , deps : [ UIRouter ] } ,
191
+ { provide : Globals , useFactory : fnGlobals , deps : [ UIRouter ] } ,
184
192
] ;
185
193
186
194
/**
@@ -189,4 +197,3 @@ export const _UIROUTER_SERVICE_PROVIDERS: Provider[] = [
189
197
* @deprecated use [[UIRouterModule.forRoot]]
190
198
*/
191
199
export const UIROUTER_PROVIDERS : Provider [ ] = _UIROUTER_INSTANCE_PROVIDERS . concat ( _UIROUTER_SERVICE_PROVIDERS ) ;
192
-
0 commit comments