填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

@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.

入口点

Entry points

主要

Primary

@angular/router

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

次要

Secondary

@angular/router/testing

Supplies a testing module for the Angular Router subsystem.

@angular/router/upgrade

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

主要入口点的导出

Primary entry point exports

NgModules

RouterModule

添加指令和提供者,以便在应用程序中定义的视图之间进行应用内导航。使用 Angular Router 服务以声明方式指定应用程序状态并管理状态转换。

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.

Classes

ActivatedRoute

允许访问与某出口中加载的组件关联路由信息。用于遍历 RouterState 树并从节点提取信息。

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

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.

ActivationEnd

在路由的“解析”阶段的激活部分结束时触发的事件。

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

ActivationStart

在路由的“解析”阶段的激活部分开始时触发的事件。

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

BaseRouteReuseStrategy

此基本路由复用策略仅在匹配的路由器配置完全相同时复用路由。这样可以防止仅在片段或查询参数发生更改时销毁和重新创建组件(也就是复用现有组件)。

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

ChildActivationEnd

在路由的“解析”阶段的子路由激活部分结束时触发的事件。

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

ChildActivationStart

在路由的“解析”阶段的子路由激活部分开始时触发的事件。

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

ChildrenOutletContexts

存储关于子级(=嵌套)RouterOutlet 的上下文信息。

Store contextual information about the children (= nested) RouterOutlet

DefaultUrlSerializer

UrlSerializer 的默认实现。

A default implementation of the UrlSerializer.

GuardsCheckEnd

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

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

GuardsCheckStart

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

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

NavigationCancel

直接或间接取消导航时触发的事件。当路由守卫返回了 false,或返回了 UrlTree 以发起重定向时,可能会发生这种情况。

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

NavigationEnd

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

An event triggered when a navigation ends successfully.

NavigationError

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

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

NavigationStart

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

An event triggered when a navigation starts.

NoPreloading

提供不预加载任何模块的预加载策略。

Provides a preloading strategy that does not preload any modules.

OutletContext

存储关于 RouterOutlet 的上下文信息

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

在路由的“解析”阶段结束时触发的事件。

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

ResolveStart

在路由的“解析”阶段开始时触发的事件。

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

RouteConfigLoadEnd

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

An event triggered when a route has been lazy loaded.

RouteConfigLoadStart

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

An event triggered before lazy loading a route configuration.

RouteReuseStrategy

提供一种自定义复用已激活路由的方式。

Provides a way to customize when activated routes get reused.

Router

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

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

RouterEvent

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

Base for events the router goes through, as opposed to events tied to a specific route. 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.

RouterState

将路由器的状态表示为已激活路由的树。

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

RouterStateSnapshot

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

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

RoutesRecognized

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

An event triggered when routes are recognized.

Scroll

表示一个滚动事件。

An event triggered by scrolling.

UrlHandlingStrategy

提供一种将 AngularJS 应用程序迁移到 Angular 的方法。

Provides a way to migrate AngularJS applications to Angular.

UrlSegment

表示一个 URL 段。

Represents a single URL segment.

UrlSegmentGroup

表示已解析的 URL 段组。

Represents the parsed URL segment group.

UrlSerializer

将 URL 字符串序列化和反序列化为 URL 树。

Serializes and deserializes a URL string into a URL tree.

UrlTree

代表已解析的 URL。

Represents the parsed URL.

函数

Functions

convertToParamMap

Params 实例转换为 ParamMap

Converts a Params instance to a ParamMap.

provideRoutes

为一组路由注册一个 DI 提供者。

Registers a DI provider for a set of routes.

结构

Structures

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 continues. If any guard returns false, navigation is cancelled. If any guard returns a UrlTree, the current navigation is cancelled and a new navigation begins 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 continues. If any guard returns false, navigation is cancelled. If any guard returns a UrlTree, current navigation is cancelled and a new navigation begins 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 continues. If any guard returns false, navigation is cancelled. If any guard returns a UrlTree, current navigation is cancelled and a new navigation begins to the UrlTree returned from the guard.

CanLoad

类可以实现的接口,用于确定是否可以加载子路由。如果所有守卫都返回了 true,那么导航将继续。如果任何守卫返回 false,则导航将被取消。如果任何守卫返回 UrlTree ,当前导航被取消,新的导航开始到守卫所返回的 UrlTree

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

ExtraOptions

forRoot() 方法中提供的一组路由器模块配置选项。

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

IsActiveMatchOptions

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

NavigationBehaviorOptions

修改 Router 导航策略的选项。为 Router 导航功能提供包含任何这些属性的对象,以控制导航的处理方式。

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

NavigationExtras

修改 Router 导航策略的选项。为 Router 导航功能提供包含任何这些属性的对象,以控制应如何构造或解释目标 URL。

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

ParamMap

提供访问特定于路由的必需和可选参数的映射表。该映射表支持使用 get() 检索单个值或使用 getAll() 检索多个值。

A map that provides access to the required and optional parameters specific to a route. The map supports retrieving a single value with get() or multiple values with getAll().

Resolve

可以实现为数据提供者的类的接口。数据提供者类可与路由器一起使用,以在导航期间解析数据。接口定义了开始导航时调用 resolve() 路由器在最终激活路由之前等待数据解析。

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

Route

定义单个路由的配置对象。在 Routes 数组中收集了一组路由定义,以用作 Router 的配置。路由器会尝试使用此对象中定义的配置选项,将给定 URL 段与每个路由进行匹配。

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

RouterOutletContract

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

UrlCreationOptions

本选项用来修改 Router 的 URL。向 Router 导航功能提供包含任何这些属性的对象,以控制应如何构造目标 URL。

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

指令

Directives

RouterLink

当应用于模板中的元素时,使该元素成为开始导航到某个路由的链接。导航会在页面上的 <router-outlet> 位置上打开一个或多个路由组件。

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

RouterLinkActive

跟踪元素上的链接路由当前是否处于活动状态,并允许你指定一个或多个 CSS 类,以便在链接路由处于活动状态时添加到该元素。

Tracks whether the linked route of an element is currently active, and allows you to specify one or more CSS classes to add to the element when the linked route is 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.

类型

Types

Data

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

Represents static data associated with a particular route.

DeprecatedLoadChildren

已弃用: The string form of loadChildren is deprecated in favor of the LoadChildrenCallback function which uses the ES dynamic import() expression. This offers a more natural and standards-based mechanism to dynamically load an ES module at runtime.

不推荐使用 loadChildrenstring 形式,而推荐使用使用 ES 的动态 import() 表达式 LoadChildrenCallback。这提供了一种更自然且基于标准的机制,可在运行时动态加载 ES 模块。

格式为 path/to/file#exportName ,用作要加载的一组路由的 URL。

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

DetachedRouteHandle

表示已分离的路由树。

Represents the detached route tree.

Event

路由器事件能让你跟踪路由器的生命周期。

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

InitialNavigation

ExtraOptions 对象中的允许值,用于配置路由器何时执行初始导航操作。

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

LoadChildren

本函数返回一组要加载的路由。

A function that returns a set of routes to load.

LoadChildrenCallback

调用此函数以解析惰性加载的路由集合。必须是以下形式的箭头函数: () => import('...').then(mod => mod.MODULE)

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

Navigation

有关导航操作的信息。使用 Router.getCurrentNavigation() 方法检索最新的导航对象。

Information about a navigation operation. Retrieve the most recent navigation object with the Router.getCurrentNavigation() method .

PRIMARY_OUTLET

主路由出口的名字。

The primary routing outlet.

Params

矩阵和查询 URL 参数的集合。

A collection of matrix and query URL parameters.

QueryParamsHandling

如何处理路由器链接中的查询参数。为下列值之一:

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

ROUTER_CONFIGURATION

DI 用它来配置路由器。

A DI token for the router service.

ROUTER_INITIALIZER

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

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

ROUTES

路由器配置的 DI 令牌。

The DI token for a router configuration.

ResolveData

表示与特定路由关联的已解析数据。

Represents the resolved data associated with a particular route.

Routes

表示路由器服务的路由配置。是一个 Route 对象的数组,用作 Router.configRoute.children 中的嵌套路由配置。

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

RunGuardsAndResolvers

何时在路由上运行守卫(guard)和解析器(resolver)的策略。

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

UrlMatchResult

表示使用自定义匹配函数时的 URL 匹配结果。

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

UrlMatcher

一个用于匹配路由和 URL 的函数。 当 pathpathMatch 的组合不足以表达时,可以为 Route.matcher 实现一个自定义的 URL 匹配器。

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