MCPcopy
hub / github.com/angular/angular / withExperimentalPlatformNavigation

Function withExperimentalPlatformNavigation

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

Source from the content-addressed store, hash-verified

244 * @returns A `RouterFeature` that enables the platform navigation.
245 */
246export 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
273export function getBootstrapListener() {
274 const injector = inject(Injector);

Calls 3

injectFunction · 0.90
routerFeatureFunction · 0.85

Tested by 1

createNavigationHistoryFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…