99import { Location , LocationStrategy , PathLocationStrategy } from '@angular/common' ;
1010import { APP_INITIALIZER , AppModuleFactoryLoader , ApplicationRef , ComponentResolver , Injector , OpaqueToken , SystemJsAppModuleLoader } from '@angular/core' ;
1111
12- import { RouterConfig } from './config' ;
12+ import { Routes } from './config' ;
1313import { Router } from './router' ;
14- import { ROUTER_CONFIG } from './router_config_loader' ;
14+ import { ROUTER_CONFIG , ROUTES } from './router_config_loader' ;
1515import { RouterOutletMap } from './router_outlet_map' ;
1616import { ActivatedRoute } from './router_state' ;
1717import { DefaultUrlSerializer , UrlSerializer } from './url_tree' ;
1818
19- export const ROUTER_OPTIONS = new OpaqueToken ( 'ROUTER_OPTIONS ' ) ;
19+ export const ROUTER_CONFIGURATION = new OpaqueToken ( 'ROUTER_CONFIGURATION ' ) ;
2020
2121/**
2222 * @experimental
@@ -26,7 +26,7 @@ export interface ExtraOptions { enableTracing?: boolean; }
2626export function setupRouter (
2727 ref : ApplicationRef , resolver : ComponentResolver , urlSerializer : UrlSerializer ,
2828 outletMap : RouterOutletMap , location : Location , injector : Injector ,
29- loader : AppModuleFactoryLoader , config : RouterConfig , opts : ExtraOptions ) {
29+ loader : AppModuleFactoryLoader , config : Routes , opts : ExtraOptions ) {
3030 if ( ref . componentTypes . length == 0 ) {
3131 throw new Error ( 'Bootstrap at least one component before injecting Router.' ) ;
3232 }
@@ -82,18 +82,20 @@ export function setupRouterInitializer(injector: Injector) {
8282 *
8383 * @deprecated use RouterAppModule instead
8484 */
85- export function provideRouter ( _config : RouterConfig , _opts : ExtraOptions ) : any [ ] {
85+ export function provideRouter ( routes : Routes , config : ExtraOptions ) : any [ ] {
8686 return [
87- { provide : ROUTER_CONFIG , useValue : _config } , { provide : ROUTER_OPTIONS , useValue : _opts } ,
88- Location , { provide : LocationStrategy , useClass : PathLocationStrategy } ,
87+ { provide : ROUTES , useExisting : ROUTER_CONFIG } , { provide : ROUTER_CONFIG , useValue : routes } ,
88+
89+ { provide : ROUTER_CONFIGURATION , useValue : config } , Location ,
90+ { provide : LocationStrategy , useClass : PathLocationStrategy } ,
8991 { provide : UrlSerializer , useClass : DefaultUrlSerializer } ,
9092
9193 {
9294 provide : Router ,
9395 useFactory : setupRouter ,
9496 deps : [
9597 ApplicationRef , ComponentResolver , UrlSerializer , RouterOutletMap , Location , Injector ,
96- AppModuleFactoryLoader , ROUTER_CONFIG , ROUTER_OPTIONS
98+ AppModuleFactoryLoader , ROUTES , ROUTER_CONFIGURATION
9799 ]
98100 } ,
99101
@@ -122,8 +124,8 @@ export function provideRouter(_config: RouterConfig, _opts: ExtraOptions): any[]
122124 *
123125 * @experimental
124126 */
125- export function provideRoutes ( config : RouterConfig ) : any {
126- return { provide : ROUTER_CONFIG , useValue : config } ;
127+ export function provideRoutes ( routes : Routes ) : any {
128+ return { provide : ROUTES , useValue : routes } ;
127129}
128130
129131/**
@@ -142,6 +144,6 @@ export function provideRoutes(config: RouterConfig): any {
142144 *
143145 * @experimental
144146 */
145- export function provideRouterConfig ( options : ExtraOptions ) : any {
146- return { provide : ROUTER_OPTIONS , useValue : options } ;
147+ export function provideRouterConfig ( config : ExtraOptions ) : any {
148+ return { provide : ROUTER_CONFIGURATION , useValue : config } ;
147149}
0 commit comments