()
| 244 | * @returns A `RouterFeature` that enables the platform navigation. |
| 245 | */ |
| 246 | export function withExperimentalPlatformNavigation(): ExperimentalPlatformNavigationFeature { |
| 247 | const devModeLocationCheck = |
| 248 | typeof ngDevMode === 'undefined' || ngDevMode |
| 249 | ? [ |
| 250 | provideEnvironmentInitializer(() => { |
| 251 | const locationInstance = inject(Location); |
| 252 | if (!(locationInstance instanceof ɵNavigationAdapterForLocation)) { |
| 253 | const locationConstructorName = (locationInstance as any).constructor.name; |
| 254 | let message = |
| 255 | `'withExperimentalPlatformNavigation' provides a 'Location' implementation that ensures navigation APIs are consistently used.` + |
| 256 | ` An instance of ${locationConstructorName} was found instead.`; |
| 257 | if (locationConstructorName === 'SpyLocation') { |
| 258 | message += ` One of 'RouterTestingModule' or 'provideLocationMocks' was likely used. 'withExperimentalPlatformNavigation' does not work with these because they override the Location implementation.`; |
| 259 | } |
| 260 | throw new Error(message); |
| 261 | } |
| 262 | }), |
| 263 | ] |
| 264 | : []; |
| 265 | const providers = [ |
| 266 | {provide: StateManager, useExisting: NavigationStateManager}, |
| 267 | {provide: Location, useClass: ɵNavigationAdapterForLocation}, |
| 268 | devModeLocationCheck, |
| 269 | ]; |
| 270 | return routerFeature(RouterFeatureKind.ExperimentalPlatformNavigationFeature, providers); |
| 271 | } |
| 272 | |
| 273 | export function getBootstrapListener() { |
| 274 | const injector = inject(Injector); |
searching dependent graphs…