MCPcopy Create free account
hub / github.com/angular/angular / withExperimentalPlatformNavigation

Function withExperimentalPlatformNavigation

packages/router/src/provide_router.ts:247–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Calls 3

injectFunction · 0.90
routerFeatureFunction · 0.85

Tested by 1

createNavigationHistoryFunction · 0.72