@angular/router

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

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

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

入口点

主要

@angular/router

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

次要

@angular/router/testing
@angular/router/upgrade

主入口点的导出

模块

RouterModule

添加路由器指令和服务提供商。

Adds router directives and providers.

ActivationEnd

Represents the start of end of the Resolve phase of routing. See note on ActivationStart for use of this experimental API.

ActivationStart

Represents the start of end of the Resolve phase of routing. See note on ActivationEnd for use of this experimental API.

ChildActivationEnd

Represents the start of end of the Resolve phase of routing. See note on ChildActivationStart for use of this experimental API.

ChildActivationStart

Represents the start of end of the Resolve phase of routing. See note on ChildActivationEnd for use of this experimental API.

ChildrenOutletContexts

Store contextual information about the children (= nested) RouterOutlet

DefaultUrlSerializer

A default implementation of the UrlSerializer.

GuardsCheckEnd

表示路由的守卫(Guard)阶段的结束。

Represents the end of the Guard phase of routing.

GuardsCheckStart

表示路由的守卫(Guard)阶段的开始。

Represents the start of the Guard phase of routing.

NavigationCancel

表示当导航被取消时触发的事件。

Represents an event triggered when a navigation is canceled.

NavigationEnd

表示当导航成功结束时触发的事件。

Represents an event triggered when a navigation ends successfully.

NavigationError

表示当导航出错时触发的事件。

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

NavigationStart

代表导航开始时触发的事件。

Represents an event triggered when a navigation starts.

NoPreloading

Provides a preloading strategy that does not preload any modules.

OutletContext

Store contextual information about a RouterOutlet

PreloadAllModules

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

PreloadingStrategy

Provides a preloading strategy.

ResolveEnd

表示路由解析(Resolve)阶段的结束。参见 ResolveStart 上的注释以了解这个试验性 API 的用法。

Represents the end of the Resolve phase of routing. See note on ResolveStart for use of this experimental API.

ResolveStart

表示路由解析(Resolve)阶段的开始。该事件的触发时机将来可能会改变,因为它是试验性的。 在当前的迭代中,它将会在 resolve 阶段执行,而不管有没有东西要 resolve。 将来,这种行为可能会修改成只有当有东西要 resolve 时才执行。

Represents the start of the Resolve phase of routing. The timing of this event may change, thus it's experimental. In the current iteration it will run in the "resolve" phase whether there's things to resolve or not. In the future this behavior may change to only run when there are things to be resolved.

RouteConfigLoadEnd

表示当某个路由被惰性加载时触发的事件。

Represents an event triggered when a route has been lazy loaded.

RouteConfigLoadStart

表示在惰性加载某个路由配置前触发的事件。

Represents an event triggered before lazy loading a route config.

RouteReuseStrategy

Provides a way to customize when activated routes get reused.

Router

提供导航和操纵 URL 的能力。

Provides the navigation and url manipulation capabilities.

RouterEvent

路由器相关事件的(而不是关于特定路由的)基类。对于任何指定的导航,RouterEvent 只会触发一次。

Base for events the Router goes through, as opposed to events tied to a specific Route. RouterEvents will only be fired one time for any given navigation.

RouterPreloader

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

RoutesRecognized

表示当路由被识别出来时触发的事件。

Represents an event triggered when routes are recognized.

Scroll

表示一个滚动事件。

Represents a scrolling event.

UrlHandlingStrategy

Provides a way to migrate AngularJS applications to Angular.

UrlSegment

Represents a single URL segment.

UrlSegmentGroup

Represents the parsed URL segment group.

UrlSerializer

Serializes and deserializes a URL string into a URL tree.

函数

convertToParamMap

Convert a Params instance to a ParamMap.

provideRoutes

注册路由。

Registers routes.

结构

ActivatedRoute

包含与当前组件相关的路由信息。ActivatedRoute 也可用于遍历路由器的状态树。

Contains the information about a route associated with a component loaded in an outlet. An ActivatedRoute can also be used to traverse the router state tree.

ActivatedRouteSnapshot

包含与当前组件相关的路由的当前瞬间信息。ActivatedRoute 也可用于遍历路由器的状态树。 ActivatedRouteSnapshot 也能用于遍历路由器状态树。

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

CanActivate

一个接口,某些类可以实现它以扮演一个守卫,来决定该路由能否激活。 如果所有守卫都返回 true,就会继续导航。如果任何一个守卫返回了 false,就会取消导航。 如果任何一个守卫返回了 UrlTree,就会取消当前导航,并开始导航到这个守卫所返回的 UrlTree

Interface that a class can implement to be a guard deciding if a route can be activated. If all guards return true, navigation will continue. If any guard returns false, navigation will be cancelled. If any guard returns a UrlTree, current navigation will be cancelled and a new navigation will be kicked off to the UrlTree returned from the guard.

CanActivateChild

一个接口,某些类可以实现它以扮演一个守卫,来决定该路由的子路由能否激活。 如果所有守卫都返回 true,就会继续导航。如果任何一个守卫返回了 false,就会取消导航。 如果任何一个守卫返回了 UrlTree,就会取消当前导航,并开始导航到这个守卫所返回的 UrlTree

Interface that a class can implement to be a guard deciding if a child route can be activated. If all guards return true, navigation will continue. If any guard returns false, navigation will be cancelled. If any guard returns a UrlTree, current navigation will be cancelled and a new navigation will be kicked off to the UrlTree returned from the guard.

CanDeactivate

一个接口,某些类可以实现它以扮演一个守卫,来决定该路由能否停用。 如果所有守卫都返回 true,就会继续导航。如果任何一个守卫返回了 false,就会取消导航。 如果任何一个守卫返回了 UrlTree,就会取消当前导航,并开始导航到这个守卫所返回的 UrlTree

Interface that a class can implement to be a guard deciding if a route can be deactivated. If all guards return true, navigation will continue. If any guard returns false, navigation will be cancelled. If any guard returns a UrlTree, current navigation will be cancelled and a new navigation will be kicked off to the UrlTree returned from the guard.

CanLoad

一个接口,某些类可以实现它以扮演一个守卫,来决定该路由的子路由能否加载。

Interface that a class can implement to be a guard deciding if a children can be loaded.

ExtraOptions

表示路由器的配置项。

Represents options to configure the router.

NavigationExtras

表示在导航时用到的额外选项。

Represents the extra options used during navigation.

ParamMap

矩阵参数(;)和查询参数(?)。

Matrix and Query parameters.

Resolve

一个接口,某些类可以实现它以扮演一个数据提供者。

Interface that class can implement to be a data provider.

Route

欲知详情,参见 Routes

See Routes for more details.

RouterState

Represents the state of the router.

RouterStateSnapshot

表示路由器在当前瞬间的状态。

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

UrlTree

Represents the parsed URL.

指令

RouterLink

让你可以在应用中链接到特定的路由。

Lets you link to specific routes in your app.

RouterLinkActive

当此链接指向的路由激活时,往宿主元素上添加一个 CSS 类。

Lets you add a CSS class to an element when the link's route becomes active.

RouterLinkWithHref

允许你在应用中链接到特定的路由。

Lets you link to specific routes in your app.

RouterOutlet

一个占位符,Angular 会根据当前的路由器状态动态填充它。

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

类型

Data

表示与特定路由相关的静态数据。

Represents the static data associated with a particular route.

DetachedRouteHandle

Represents the detached route tree.

Event

表示一个路由器事件,允许你跟踪路由器本身的生命周期。

Represents a router event, allowing you to track the lifecycle of the router.

LoadChildren

loadChildren 的类型定义。

The type of loadChildren.

LoadChildrenCallback

loadChildren 的类型定义。

The type of loadChildren.

Navigation

Information about any given navigation. This information can be gotten from the router at any time using the router.getCurrentNavigation() method.

PRIMARY_OUTLET

Name of the primary outlet.

Params

A collection of parameters.

ROUTER_CONFIGURATION

DI 用它来配置路由器。

Is used in DI to configure the router.

ROUTER_INITIALIZER

一个代表路由器初始化器的令牌,应用引导完毕后就会调用它。

A token for the router initializer that will be called after the app is bootstrapped.

ROUTES
ResolveData

表示与特定路由相关的解析出来的数据。

Represents the resolved data associated with a particular route.

Routes

表示路由器配置。

Represents router configuration.

RunGuardsAndResolvers

runGuardsAndResolvers 的类型定义。

The type of runGuardsAndResolvers.

UrlMatchResult

表示 URL 匹配的结果。

Represents the results of the URL matching.

UrlMatcher

用于匹配 URL 的函数

A function matching URLs