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

Function withExperimentalPlatformNavigation

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

Source from the content-addressed store, hash-verified

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

Callers 6

configureTestingModuleFunction · 0.90
setupFunction · 0.90

Calls 3

injectFunction · 0.90
routerFeatureFunction · 0.85

Tested by 2

configureTestingModuleFunction · 0.72
setupFunction · 0.72