Angular 路由
Angular Routing
在單頁應用中,你可以透過顯示或隱藏與特定元件相對應的部分來更改使用者看到的內容,而不用去伺服器獲取新頁面。使用者執行應用程式任務時,他們需要在定義好的不同檢視之間移動。
In a single-page app, you change what the user sees by showing or hiding portions of the display that correspond to particular components, rather than going out to the server to get a new page. As users perform application tasks, they need to move between the different views that you have defined.
要處理從一個檢視到下一個檢視的導航,請使用 Angular Router
。 Router
會透過將瀏覽器 URL 解釋為更改檢視的操作指令來啟用導航。
To handle the navigation from one view to the next, you use the Angular Router
. The Router
enables navigation by interpreting a browser URL as an instruction to change the view.
要瀏覽具有主要路由器功能的示例應用,請參閱
To explore a sample app featuring the router's primary features, see the
先決條件
Prerequisites
在建立路線之前,你應該熟悉以下內容:
Before creating a route, you should be familiar with the following:
一個 Angular 應用程式 - 你可以使用 Angular CLI 產生基本的 Angular 應用程式。
An Angular app—you can generate a basic Angular app using the Angular CLI.
瞭解 Angular 路由
Learn about Angular routing
學習如何實現與 Angular 路由有關的多種常見路由任務。
Learn how to implement many of the common tasks associated with Angular routing.
一個涵蓋與 Angular 路由有關的多種模式的課程。
A tutorial that covers patterns associated with Angular routing.
往《英雄之旅》課程中新增更多路由特性。
Add more routing features to the Tour of Heroes tutorial.
講述一些核心路由器 API 的概念。
Describes some core router API concepts.