填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫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.