` parent tag
* when the URL is either '/user/jim' or '/user/bob'.
*
* ```html
*
* ```
*
* The `RouterLinkActive` directive can also be used to set the aria-current attribute
* to provide an alternative distinction for active elements to visually impaired users.
*
* For example, the following code adds the 'active' class to the Home Page link when it is
* indeed active and in such case also sets its aria-current attribute to 'page':
*
* ```html
*
Home Page
* ```
*
* NOTE: RouterLinkActive is a `ContentChildren` query.
* Content children queries do not retrieve elements or directives that are in other components' templates, since a component's template is always a black box to its ancestors.
*
* @ngModule RouterModule
*
* @see [Detect active current route with RouterLinkActive](guide/routing/read-route-state#detect-active-current-route-with-routerlinkactive)
*
* @publicApi
*/
declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
private router;
private element;
private renderer;
private readonly cdr;
links: QueryList
;
private classes;
private routerEventsSubscription;
private linkInputChangesSubscription?;
private _isActive;
get isActive(): boolean;
/**
* Options to configure how to determine if the router link is active.
*
* These options are passed to the `isActive()` function.
*
* @see {@link isActive}
*/
routerLinkActiveOptions: {
exact: boolean;
} | Partial;
/**
* Aria-current attribute to apply when the router link is active.
*
* Possible values: `'page'` | `'step'` | `'location'` | `'date'` | `'time'` | `true` | `false`.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current}
*/
ariaCurrentWhenActive?: 'page' | 'step' | 'location' | 'date' | 'time' | true | false;
/**
*
* You can use the output `isActiveChange` to get notified each time the link becomes
* active or inactive.
*
* Emits:
* true -> Route is active
* false -> Route is inactive
*
* ```html
* Bob
* ```
*/
readonly isActiveChange: EventEmitter;
private link;
constructor(router: Router, element: ElementRef, renderer: Renderer2, cdr: ChangeDetectorRef);
/** @docs-private */
ngAfterContentInit(): void;
private subscribeToEachLinkOnChanges;
set routerLinkActive(data: string[] | string);
/** @docs-private */
ngOnChanges(changes: SimpleChanges): void;
/** @docs-private */
ngOnDestroy(): void;
private update;
private isLinkActive;
private hasActiveLinks;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵdir: i0.ɵɵDirectiveDeclaration;
}
/**
* Allowed values in an `ExtraOptions` object that configure
* when the router performs the initial navigation operation.
*
* * 'enabledNonBlocking' - (default) The initial navigation starts after the
* root component has been created. The bootstrap is not blocked on the completion of the initial
* navigation.
* * 'enabledBlocking' - The initial navigation starts before the root component is created.
* The bootstrap is blocked until the initial navigation is complete. This value should be set in
* case you use [server-side rendering](guide/ssr), but do not enable [hydration](guide/hydration)
* for your application.
* * 'disabled' - The initial navigation is not performed. The location listener is set up before
* the root component gets created. Use if there is a reason to have
* more control over when the router starts its initial navigation due to some complex
* initialization logic.
*
* @see {@link /api/router/RouterModule#forRoot forRoot}
*
* @publicApi
*/
type InitialNavigation = 'disabled' | 'enabledBlocking' | 'enabledNonBlocking';
/**
* Extra configuration options that can be used with the `withRouterConfig` function.
*
* @see [Router configuration options](guide/routing/customizing-route-behavior#router-configuration-options)
*
* @publicApi
*/
interface RouterConfigOptions {
/**
* Configures how the Router attempts to restore state when a navigation is cancelled.
*
* 'replace' - Always uses `location.replaceState` to set the browser state to the state of the
* router before the navigation started. This means that if the URL of the browser is updated
* _before_ the navigation is canceled, the Router will simply replace the item in history rather
* than trying to restore to the previous location in the session history. This happens most
* frequently with `urlUpdateStrategy: 'eager'` and navigations with the browser back/forward
* buttons.
*
* 'computed' - Will attempt to return to the same index in the session history that corresponds
* to the Angular route when the navigation gets cancelled. For example, if the browser back
* button is clicked and the navigation is cancelled, the Router will trigger a forward navigation
* and vice versa.
*
* Note: the 'computed' option is incompatible with any `UrlHandlingStrategy` which only
* handles a portion of the URL because the history restoration navigates to the previous place in
* the browser history rather than simply resetting a portion of the URL.
*
* The default value is `replace` when not set.
*
* @see [Handle canceled navigations](guide/routing/customizing-route-behavior#handle-canceled-navigations)
*
*/
canceledNavigationResolution?: 'replace' | 'computed';
/**
* Configures the default for handling a navigation request to the current URL.
*
* If unset, the `Router` will use `'ignore'`.
*
* @see {@link OnSameUrlNavigation}
*
* @see [React to same-URL navigations](guide/routing/customizing-route-behavior#react-to-same-url-navigations)
*/
onSameUrlNavigation?: OnSameUrlNavigation;
/**
* Defines how the router merges parameters, data, and resolved data from parent to child
* routes.
*
* By default ('emptyOnly'), a route inherits the parent route's parameters when the route itself
* has an empty path (meaning its configured with path: '') or when the parent route doesn't have
* any component set.
*
* Set to 'always' to enable unconditional inheritance of parent parameters.
*
* Note that when dealing with matrix parameters, "parent" refers to the parent `Route`
* config which does not necessarily mean the "URL segment to the left". When the `Route` `path`
* contains multiple segments, the matrix parameters must appear on the last segment. For example,
* matrix parameters for `{path: 'a/b', component: MyComp}` should appear as `a/b;foo=bar` and not
* `a;foo=bar/b`.
*
* @see [Control parameter inheritance](guide/routing/customizing-route-behavior#control-parameter-inheritance)
*
*/
paramsInheritanceStrategy?: 'emptyOnly' | 'always';
/**
* Defines when the router updates the browser URL. By default ('deferred'),
* update after successful navigation.
* Set to 'eager' if prefer to update the URL at the beginning of navigation.
* Updating the URL early allows you to handle a failure of navigation by
* showing an error message with the URL that failed.
*
* @see [Decide when the URL updates](guide/routing/customizing-route-behavior#decide-when-the-url-updates)
*
*/
urlUpdateStrategy?: 'deferred' | 'eager';
/**
* The default strategy to use for handling query params in `Router.createUrlTree` when one is not provided.
*
* The `createUrlTree` method is used internally by `Router.navigate` and `RouterLink`.
* Note that `QueryParamsHandling` does not apply to `Router.navigateByUrl`.
*
* When neither the default nor the queryParamsHandling option is specified in the call to `createUrlTree`,
* the current parameters will be replaced by new parameters.
*
* @see {@link Router#createUrlTree}
* @see {@link QueryParamsHandling}
*
* @see [Choose default query parameter handling](guide/routing/customizing-route-behavior#choose-default-query-parameter-handling)
*
*/
defaultQueryParamsHandling?: QueryParamsHandling;
/**
* When `true`, the `Promise` will instead resolve with `false`, as it does with other failed
* navigations (for example, when guards are rejected).
* Otherwise the `Promise` returned by the Router's navigation with be rejected
* if an error occurs.
*/
resolveNavigationPromiseOnError?: boolean;
}
/**
* Configuration options for the scrolling feature which can be used with `withInMemoryScrolling`
* function or `RouterModule.forRoot`.
*
* @publicApi
* @see withInMemoryScrolling
* @see RouterModule#forRoot
*/
interface InMemoryScrollingOptions {
/**
* When set to 'enabled', scrolls to the anchor element when the URL has a fragment.
* Anchor scrolling is disabled by default.
*
* Anchor scrolling does not happen on 'popstate'. Instead, we restore the position
* that we stored or scroll to the top.
*/
anchorScrolling?: 'disabled' | 'enabled';
/**
* Configures if the scroll position needs to be restored when navigating back.
*
* * 'disabled'- (Default) Does nothing. Scroll position is maintained on navigation.
* * 'top'- Sets the scroll position to x = 0, y = 0 on all navigation.
* * 'enabled'- Restores the previous scroll position on backward navigation, else sets the
* position to the anchor if one is provided, or sets the scroll position to [0, 0] (forward
* navigation). This option will be the default in the future.
*
* You can implement custom scroll restoration behavior by adapting the enabled behavior as
* in the following example.
*
* ```ts
* class AppComponent {
* movieData: any;
*
* constructor(private router: Router, private viewportScroller: ViewportScroller,
* changeDetectorRef: ChangeDetectorRef) {
* router.events.pipe(filter((event: Event): event is Scroll => event instanceof Scroll)
* ).subscribe(e => {
* fetch('http://example.com/movies.json').then(response => {
* this.movieData = response.json();
* // update the template with the data before restoring scroll
* changeDetectorRef.detectChanges();
*
* if (e.position) {
* viewportScroller.scrollToPosition(e.position);
* }
* });
* });
* }
* }
* ```
*/
scrollPositionRestoration?: 'disabled' | 'enabled' | 'top';
}
/**
* A set of configuration options for a router module, provided in the
* `forRoot()` method.
*
* @see {@link /api/router/routerModule#forRoot forRoot}
*
*
* @publicApi
*/
interface ExtraOptions extends InMemoryScrollingOptions, RouterConfigOptions {
/**
* When true, log all internal navigation events to the console.
* Use for debugging.
*/
enableTracing?: boolean;
/**
* When true, enable the location strategy that uses the URL fragment
* instead of the history API.
*/
useHash?: boolean;
/**
* One of `enabled`, `enabledBlocking`, `enabledNonBlocking` or `disabled`.
* When set to `enabled` or `enabledBlocking`, the initial navigation starts before the root
* component is created. The bootstrap is blocked until the initial navigation is complete. This
* value should be set in case you use [server-side rendering](guide/ssr), but do not enable
* [hydration](guide/hydration) for your application. When set to `enabledNonBlocking`,
* the initial navigation starts after the root component has been created.
* The bootstrap is not blocked on the completion of the initial navigation. When set to
* `disabled`, the initial navigation is not performed. The location listener is set up before the
* root component gets created. Use if there is a reason to have more control over when the router
* starts its initial navigation due to some complex initialization logic.
*/
initialNavigation?: InitialNavigation;
/**
* When true, enables binding information from the `Router` state directly to the inputs of the
* component in `Route` configurations.
*/
bindToComponentInputs?: boolean;
/**
* When true, enables view transitions in the Router by running the route activation and
* deactivation inside of `document.startViewTransition`.
*
* @see https://developer.chrome.com/docs/web-platform/view-transitions/
* @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
* @experimental 17.0
*/
enableViewTransitions?: boolean;
/**
* A custom error handler for failed navigations.
* If the handler returns a value, the navigation Promise is resolved with this value.
* If the handler throws an exception, the navigation Promise is rejected with the exception.
*
* @see RouterConfigOptions
*/
errorHandler?: (error: any) => RedirectCommand | any;
/**
* Configures a preloading strategy.
* One of `PreloadAllModules` or `NoPreloading` (the default).
*/
preloadingStrategy?: any;
/**
* Configures the scroll offset the router will use when scrolling to an element.
*
* When given a tuple with x and y position value,
* the router uses that offset each time it scrolls.
* When given a function, the router invokes the function every time
* it restores scroll position.
*/
scrollOffset?: [number, number] | (() => [number, number]);
}
/**
* A DI token for the router service.
*
* @publicApi
*/
declare const ROUTER_CONFIGURATION: InjectionToken;
/**
* This component is used internally within the router to be a placeholder when an empty
* router-outlet is needed. For example, with a config such as:
*
* `{path: 'parent', outlet: 'nav', children: [...]}`
*
* In order to render, there needs to be a component on this config, which will default
* to this `EmptyOutletComponent`.
*/
declare class ɵEmptyOutletComponent {
static ɵfac: i0.ɵɵFactoryDeclaration<ɵEmptyOutletComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ɵEmptyOutletComponent, "ng-component", ["emptyRouterOutlet"], {}, {}, never, never, true, never>;
}
declare const ROUTER_PROVIDERS: Provider[];
/**
* @description
*
* Adds directives and providers for in-app navigation among views defined in an application.
* Use the Angular `Router` service to declaratively specify application states and manage state
* transitions.
*
* You can import this NgModule multiple times, once for each lazy-loaded bundle.
* However, only one `Router` service can be active.
* To ensure this, there are two ways to register routes when importing this module:
*
* * The `forRoot()` method creates an `NgModule` that contains all the directives, the given
* routes, and the `Router` service itself.
* * The `forChild()` method creates an `NgModule` that contains all the directives and the given
* routes, but does not include the `Router` service.
*
* @see [Routing and Navigation guide](guide/routing/common-router-tasks) for an
* overview of how the `Router` service should be used.
*
* @publicApi
*/
declare class RouterModule {
constructor();
/**
* Creates and configures a module with all the router providers and directives.
* Optionally sets up an application listener to perform an initial navigation.
*
* When registering the NgModule at the root, import as follows:
*
* ```ts
* @NgModule({
* imports: [RouterModule.forRoot(ROUTES)]
* })
* class MyNgModule {}
* ```
*
* @param routes An array of `Route` objects that define the navigation paths for the application.
* @param config An `ExtraOptions` configuration object that controls how navigation is performed.
* @return The new `NgModule`.
*
*/
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders;
/**
* Creates a module with all the router directives and a provider registering routes,
* without creating a new Router service.
* When registering for submodules and lazy-loaded submodules, create the NgModule as follows:
*
* ```ts
* @NgModule({
* imports: [RouterModule.forChild(ROUTES)]
* })
* class MyNgModule {}
* ```
*
* @param routes An array of `Route` objects that define the navigation paths for the submodule.
* @return The new NgModule.
*
*/
static forChild(routes: Routes): ModuleWithProviders;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵmod: i0.ɵɵNgModuleDeclaration;
static ɵinj: i0.ɵɵInjectorDeclaration;
}
/**
* A DI token for the router initializer that
* is called after the app is bootstrapped.
*
* @publicApi
*/
declare const ROUTER_INITIALIZER: InjectionToken<(compRef: ComponentRef) => void>;
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, DefaultUrlSerializer, EventType, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationCancellationCode, NavigationEnd, NavigationError, NavigationSkipped, NavigationSkippedCode, NavigationStart, PRIMARY_OUTLET, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTER_OUTLET_DATA, ROUTER_PROVIDERS, RedirectCommand, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterModule, RouterOutlet, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, convertToParamMap, defaultUrlMatcher, destroyDetachedRouteHandle, isActive, ɵEmptyOutletComponent };
export type { CanActivate, CanActivateChild, CanActivateChildFn, CanActivateFn, CanDeactivate, CanDeactivateFn, CanLoad, CanLoadFn, CanMatch, CanMatchFn, Data, DefaultExport, DeprecatedGuard, DeprecatedResolve, DetachedRouteHandle, Event, ExtraOptions, GuardResult, InMemoryScrollingOptions, InitialNavigation, IsActiveMatchOptions, LoadChildren, LoadChildrenCallback, LoadedRouterConfig, MaybeAsync, Navigation, NavigationBehaviorOptions, NavigationExtras, OnSameUrlNavigation, ParamMap, Params, PartialMatchRouteSnapshot, QueryParamsHandling, RedirectFunction, Resolve, ResolveData, ResolveFn, RestoredState, Route, RouterConfigOptions, RouterOutletContract, Routes, RunGuardsAndResolvers, UrlCreationOptions, UrlMatchResult, UrlMatcher };