@@ -65,6 +65,8 @@ import {services} from "../common/coreservices";
65
65
import { ProviderLike } from "../state/interface" ;
66
66
import { Resolvable } from "../resolve/resolvable" ;
67
67
import { ngModuleResolvablesBuilder } from "./statebuilders/lazyLoadNgModuleResolvable" ;
68
+ import { flattenR } from "../common/common" ;
69
+ import { UIROUTER_STATES_TOKEN } from "./uiRouterNgModule" ;
68
70
69
71
export const NG1_UIROUTER_TOKEN = new OpaqueToken ( "$uiRouter" ) ;
70
72
@@ -110,18 +112,22 @@ let uiRouterFactory = (injector: Injector) => {
110
112
111
113
// Prep the tree of NgModule by placing the root NgModule's Injector on the root state.
112
114
let ng2InjectorResolvable = Resolvable . fromData ( NG2_INJECTOR_TOKEN , injector ) ;
113
- router . stateRegistry . root ( ) . resolvables . push ( ng2InjectorResolvable ) ;
115
+ registry . root ( ) . resolvables . push ( ng2InjectorResolvable ) ;
114
116
115
117
116
118
// ----------------- Initialize router -------------
117
119
// Allow states to be registered
118
- router . stateRegistry . stateQueue . autoFlush ( router . stateService ) ;
120
+ registry . stateQueue . autoFlush ( router . stateService ) ;
119
121
120
122
setTimeout ( ( ) => {
121
123
// Let the app apply custom configuration...
122
124
// (global transition hooks, deferIntercept, otherwise, etc)
123
125
routerConfig . configure ( router ) ;
124
126
127
+ // Register the states from the root NgModule [[UIRouterModule]]
128
+ let states = ( injector . get ( UIROUTER_STATES_TOKEN ) || [ ] ) . reduce ( flattenR , [ ] ) ;
129
+ states . forEach ( state => registry . register ( state ) ) ;
130
+
125
131
// Start monitoring the URL
126
132
if ( ! router . urlRouterProvider . interceptDeferred ) {
127
133
router . urlRouter . listen ( ) ;
0 commit comments