@@ -15,7 +15,7 @@ import {
1515 PathLocationStrategy ,
1616 PlatformLocation ,
1717} from '../../index' ;
18- import { Inject , InjectionToken , ModuleWithProviders , NgModule , Optional } from '@angular/core' ;
18+ import { inject , InjectionToken , ModuleWithProviders , NgModule } from '@angular/core' ;
1919import { UpgradeModule } from '@angular/upgrade/static' ;
2020
2121import { $locationShim , $locationShimProvider } from './location_shim' ;
@@ -80,26 +80,26 @@ export class LocationUpgradeModule {
8080 {
8181 provide : $locationShim ,
8282 useFactory : provide$location ,
83- deps : [ UpgradeModule , Location , PlatformLocation , UrlCodec , LocationStrategy ] ,
8483 } ,
8584 { provide : LOCATION_UPGRADE_CONFIGURATION , useValue : config ? config : { } } ,
86- { provide : UrlCodec , useFactory : provideUrlCodec , deps : [ LOCATION_UPGRADE_CONFIGURATION ] } ,
85+ { provide : UrlCodec , useFactory : provideUrlCodec } ,
8786 {
8887 provide : APP_BASE_HREF_RESOLVED ,
8988 useFactory : provideAppBaseHref ,
90- deps : [ LOCATION_UPGRADE_CONFIGURATION , [ new Inject ( APP_BASE_HREF ) , new Optional ( ) ] ] ,
9189 } ,
9290 {
9391 provide : LocationStrategy ,
9492 useFactory : provideLocationStrategy ,
95- deps : [ PlatformLocation , APP_BASE_HREF_RESOLVED , LOCATION_UPGRADE_CONFIGURATION ] ,
9693 } ,
9794 ] ,
9895 } ;
9996 }
10097}
10198
102- export function provideAppBaseHref ( config : LocationUpgradeConfig , appBaseHref ?: string ) {
99+ function provideAppBaseHref ( ) {
100+ const config = inject ( LOCATION_UPGRADE_CONFIGURATION ) ;
101+ const appBaseHref = inject ( APP_BASE_HREF , { optional : true } ) ;
102+
103103 if ( config && config . appBaseHref != null ) {
104104 return config . appBaseHref ;
105105 } else if ( appBaseHref != null ) {
@@ -108,34 +108,28 @@ export function provideAppBaseHref(config: LocationUpgradeConfig, appBaseHref?:
108108 return '' ;
109109}
110110
111- export function provideUrlCodec ( config : LocationUpgradeConfig ) {
111+ function provideUrlCodec ( ) {
112+ const config = inject ( LOCATION_UPGRADE_CONFIGURATION ) ;
112113 const codec = ( config && config . urlCodec ) || AngularJSUrlCodec ;
113114 return new ( codec as any ) ( ) ;
114115}
115116
116- export function provideLocationStrategy (
117- platformLocation : PlatformLocation ,
118- baseHref : string ,
119- options : LocationUpgradeConfig = { } ,
120- ) {
117+ function provideLocationStrategy ( ) {
118+ const platformLocation = inject ( PlatformLocation ) ;
119+ const baseHref = inject ( APP_BASE_HREF_RESOLVED ) ;
120+ const options = inject ( LOCATION_UPGRADE_CONFIGURATION ) ;
121121 return options . useHash
122122 ? new HashLocationStrategy ( platformLocation , baseHref )
123123 : new PathLocationStrategy ( platformLocation , baseHref ) ;
124124}
125125
126- export function provide$location (
127- ngUpgrade : UpgradeModule ,
128- location : Location ,
129- platformLocation : PlatformLocation ,
130- urlCodec : UrlCodec ,
131- locationStrategy : LocationStrategy ,
132- ) {
126+ function provide$location ( ) {
133127 const $locationProvider = new $locationShimProvider (
134- ngUpgrade ,
135- location ,
136- platformLocation ,
137- urlCodec ,
138- locationStrategy ,
128+ inject ( UpgradeModule ) ,
129+ inject ( Location ) ,
130+ inject ( PlatformLocation ) ,
131+ inject ( UrlCodec ) ,
132+ inject ( LocationStrategy ) ,
139133 ) ;
140134
141135 return $locationProvider . $get ( ) ;
0 commit comments