{ "id": "api/router", "title": "@angular/router", "contents": "\n\n
\n
\n
\n \n API\n
\n \n
\n \n
\n

@angular/routerlink

\n \n \n \n \n
\n\n \n\n
\n

Implements the Angular Router service , which enables navigation from one view to the next as users perform application tasks.

\n\n

Defines the Route object that maps a URL path to a component, and the RouterOutlet directive\nthat you use to place a routed view in a template, as well as a complete API for configuring, querying, and controlling the router state.

\n

Import RouterModule to use the Router service in your app.\nFor more usage information, see the Routing and Navigation guide.

\n\n\n \n\n\n \n

Entry pointslink

\n \n \n \n
\n

Primarylink

\n \n \n \n \n \n \n \n
@angular/router\n \n

Implements the Angular Router service , which enables navigation from one view to the next as users perform application tasks.

\n\n
\n
\n \n\n \n \n \n
\n

Secondarylink

\n \n \n \n \n \n \n \n \n \n \n \n \n
@angular/router/testing\n \n

Supplies a testing module for the Angular Router subsystem.

\n\n
@angular/router/upgrade\n \n

Provides support for upgrading routing applications from Angular JS to Angular.

\n\n
\n
\n \n\n \n\n

Primary entry point exportslink

\n \n \n \n \n \n
\n

NgModuleslink

\n \n \n \n \n \n \n \n
RouterModule\n \n

Adds directives and providers for in-app navigation among views defined in an application.\nUse the Angular Router service to declaratively specify application states and manage state\ntransitions.

\n\n
\n
\n \n\n \n \n \n
\n

Classeslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ActivationEnd\n \n

An event triggered at the end of the activation part\nof the Resolve phase of routing.

\n\n
ActivationStart\n \n

An event triggered at the start of the activation part\nof the Resolve phase of routing.

\n\n
BaseRouteReuseStrategy\n \n

This base route reuse strategy only reuses routes when the matched router configs are\nidentical. This prevents components from being destroyed and recreated\nwhen just the fragment or query parameters change\n(that is, the existing component is reused).

\n\n
ChildActivationEnd\n \n

An event triggered at the end of the child-activation part\nof the Resolve phase of routing.

\n\n
ChildActivationStart\n \n

An event triggered at the start of the child-activation\npart of the Resolve phase of routing.

\n\n
ChildrenOutletContexts\n \n

Store contextual information about the children (= nested) RouterOutlet

\n\n
DefaultUrlSerializer\n \n

A default implementation of the UrlSerializer.

\n\n
GuardsCheckEnd\n \n

An event triggered at the end of the Guard phase of routing.

\n\n
GuardsCheckStart\n \n

An event triggered at the start of the Guard phase of routing.

\n\n
NavigationCancel\n \n

An event triggered when a navigation is canceled, directly or indirectly.\nThis can happen when a route guard\nreturns false or initiates a redirect by returning a UrlTree.

\n\n
NavigationEnd\n \n

An event triggered when a navigation ends successfully.

\n\n
NavigationError\n \n

An event triggered when a navigation fails due to an unexpected error.

\n\n
NavigationStart\n \n

An event triggered when a navigation starts.

\n\n
NoPreloading\n \n

Provides a preloading strategy that does not preload any modules.

\n\n
OutletContext\n \n

Store contextual information about a RouterOutlet

\n\n
PreloadAllModules\n \n

Provides a preloading strategy that preloads all modules as quickly as possible.

\n\n
PreloadingStrategy\n \n

Provides a preloading strategy.

\n\n
ResolveEnd\n \n

An event triggered at the end of the Resolve phase of routing.

\n\n
ResolveStart\n \n

An event triggered at the start of the Resolve phase of routing.

\n\n
RouteConfigLoadEnd\n \n

An event triggered when a route has been lazy loaded.

\n\n
RouteConfigLoadStart\n \n

An event triggered before lazy loading a route configuration.

\n\n
RouteReuseStrategy\n \n

Provides a way to customize when activated routes get reused.

\n\n
Router\n \n

A service that provides navigation among views and URL manipulation capabilities.

\n\n
RouterEvent\n \n

Base for events the router goes through, as opposed to events tied to a specific\nroute. Fired one time for any given navigation.

\n\n
RouterPreloader\n \n

The preloader optimistically loads all router configurations to\nmake navigations into lazily-loaded sections of the application faster.

\n\n
RoutesRecognized\n \n

An event triggered when routes are recognized.

\n\n
Scroll\n \n

An event triggered by scrolling.

\n\n
UrlHandlingStrategy\n \n

Provides a way to migrate AngularJS applications to Angular.

\n\n
UrlSegment\n \n

Represents a single URL segment.

\n\n
UrlSegmentGroup\n \n

Represents the parsed URL segment group.

\n\n
UrlSerializer\n \n

Serializes and deserializes a URL string into a URL tree.

\n\n
\n
\n \n\n \n \n \n\n \n \n \n
\n

Functionslink

\n \n \n \n \n \n \n \n \n \n \n \n \n
convertToParamMap\n \n

Converts a Params instance to a ParamMap.

\n\n
provideRoutes\n \n

Registers a DI provider for a set of routes.

\n\n
\n
\n \n\n \n \n \n
\n

Structureslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
ActivatedRoute\n \n

Provides access to information about a route associated with a component\nthat is loaded in an outlet.\nUse to traverse the RouterState tree and extract information from nodes.

\n\n
ActivatedRouteSnapshot\n \n

Contains the information about a route associated with a component loaded in an\noutlet at a particular moment in time. ActivatedRouteSnapshot can also be used to\ntraverse the router state tree.

\n\n
CanActivate\n \n

Interface that a class can implement to be a guard deciding if a route can be activated.\nIf all guards return true, navigation continues. If any guard returns false,\nnavigation is cancelled. If any guard returns a UrlTree, the current navigation\nis cancelled and a new navigation begins to the UrlTree returned from the guard.

\n\n
CanActivateChild\n \n

Interface that a class can implement to be a guard deciding if a child route can be activated.\nIf all guards return true, navigation continues. If any guard returns false,\nnavigation is cancelled. If any guard returns a UrlTree, current navigation\nis cancelled and a new navigation begins to the UrlTree returned from the guard.

\n\n
CanDeactivate\n \n

Interface that a class can implement to be a guard deciding if a route can be deactivated.\nIf all guards return true, navigation continues. If any guard returns false,\nnavigation is cancelled. If any guard returns a UrlTree, current navigation\nis cancelled and a new navigation begins to the UrlTree returned from the guard.

\n\n
CanLoad\n \n

Interface that a class can implement to be a guard deciding if children can be loaded.\nIf all guards return true, navigation continues. If any guard returns false,\nnavigation is cancelled. If any guard returns a UrlTree, current navigation\nis cancelled and a new navigation starts to the UrlTree returned from the guard.

\n\n
ExtraOptions\n \n

A set of configuration options for a router module, provided in the\nforRoot() method.

\n\n
IsActiveMatchOptions\n \n

A set of options which specify how to determine if a UrlTree is active, given the UrlTree\nfor the current router state.

\n\n
NavigationBehaviorOptions\n \n

Options that modify the Router navigation strategy.\nSupply an object containing any of these properties to a Router navigation function to\ncontrol how the navigation should be handled.

\n\n
NavigationExtras\n \n

Options that modify the Router navigation strategy.\nSupply an object containing any of these properties to a Router navigation function to\ncontrol how the target URL should be constructed or interpreted.

\n\n
ParamMap\n \n

A map that provides access to the required and optional parameters\nspecific to a route.\nThe map supports retrieving a single value with get()\nor multiple values with getAll().

\n\n
Resolve\n \n

Interface that classes can implement to be a data provider.\nA data provider class can be used with the router to resolve data during navigation.\nThe interface defines a resolve() method that is invoked when the navigation starts.\nThe router waits for the data to be resolved before the route is finally activated.

\n\n
Route\n \n

A configuration object that defines a single route.\nA set of routes are collected in a Routes array to define a Router configuration.\nThe router attempts to match segments of a given URL against each route,\nusing the configuration options defined in this object.

\n\n
RouterOutletContract\n \n

An interface that defines the contract for developing a component outlet for the Router.

\n\n
RouterState\n \n

Represents the state of the router as a tree of activated routes.

\n\n
RouterStateSnapshot\n \n

Represents the state of the router at a moment in time.

\n\n
UrlCreationOptions\n \n

Options that modify the Router URL.\nSupply an object containing any of these properties to a Router navigation function to\ncontrol how the target URL should be constructed.

\n\n
UrlTree\n \n

Represents the parsed URL.

\n\n
\n
\n \n\n \n \n \n
\n

Directiveslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
RouterLink\n \n

When applied to an element in a template, makes that element a link\nthat initiates navigation to a route. Navigation opens one or more routed components\nin one or more <router-outlet> locations on the page.

\n\n
RouterLinkActive\n \n

Tracks whether the linked route of an element is currently active, and allows you\nto specify one or more CSS classes to add to the element when the linked route\nis active.

\n\n
RouterLinkWithHref\n \n

Lets you link to specific routes in your app.

\n\n
RouterOutlet\n \n

Acts as a placeholder that Angular dynamically fills based on the current router state.

\n\n
\n
\n \n\n \n \n \n\n \n \n \n
\n

Typeslink

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Data\n \n

Represents static data associated with a particular route.

\n\n
DeprecatedLoadChildren\n

Deprecated: The string form of loadChildren is deprecated in favor of the\nLoadChildrenCallback function which uses the ES dynamic import() expression.\nThis offers a more natural and standards-based mechanism to dynamically\nload an ES module at runtime.

\n\n

A string of the form path/to/file#exportName that acts as a URL for a set of routes to load.

\n\n
DetachedRouteHandle\n \n

Represents the detached route tree.

\n\n
Event\n \n

Router events that allow you to track the lifecycle of the router.

\n\n
InitialNavigation\n \n

Allowed values in an ExtraOptions object that configure\nwhen the router performs the initial navigation operation.

\n\n
LoadChildren\n \n

A function that returns a set of routes to load.

\n\n
LoadChildrenCallback\n \n

A function that is called to resolve a collection of lazy-loaded routes.\nMust be an arrow function of the following form:\n() => import('...').then(mod => mod.MODULE)

\n\n
Navigation\n \n

Information about a navigation operation.\nRetrieve the most recent navigation object with the\nRouter.getCurrentNavigation() method .

\n\n
PRIMARY_OUTLET\n \n

The primary routing outlet.

\n\n
Params\n \n

A collection of matrix and query URL parameters.

\n\n
QueryParamsHandling\n \n

How to handle query parameters in a router link.\nOne of:

\n
    \n
  • merge : Merge new with current parameters.
  • \n
  • preserve : Preserve current parameters.
  • \n
\n\n
ROUTER_CONFIGURATION\n \n

A DI token for the router service.

\n\n
ROUTER_INITIALIZER\n \n

A DI token for the router initializer that\nis called after the app is bootstrapped.

\n\n
ROUTES\n \n

The DI token for a router configuration.

\n\n
ResolveData\n \n

Represents the resolved data associated with a particular route.

\n\n
Routes\n \n

Represents a route configuration for the Router service.\nAn array of Route objects, used in Router.config and for nested route configurations\nin Route.children.

\n\n
RunGuardsAndResolvers\n \n

A policy for when to run guards and resolvers on a route.

\n\n
UrlMatchResult\n \n

Represents the result of matching URLs with a custom matching function.

\n\n
UrlMatcher\n \n

A function for matching a route against URLs. Implement a custom URL matcher\nfor Route.matcher when a combination of path and pathMatch\nis not expressive enough. Cannot be used together with path and pathMatch.

\n\n
\n
\n \n\n
\n
\n\n\n" }