Angular应用的路由指令RouterLink
Angular應用的路由指令RouterLinkapp Component html源代碼:
<h1>{{title}}</h1> <nav><a routerLink="/heroes">Heroes</a></nav> <router-outlet></router-outlet> <app-messages></app-messages>A routerLink attribute is set to “/heroes”, the string that the router matches to the route to HeroesComponent. The routerLink is the selector for the RouterLink directive that turns user clicks into router navigations. It’s another of the public directives in the RouterModule.
HTML原生標簽a的屬性routerlLink,是RouterLink指令的選擇器,將用戶點擊轉換成navigation. RouterLink是RouterModule里的公有指令。
運行時效果:點擊了超鏈接后,會跳轉到localhost:4200/heroes:
RouterLink is an inbuilt Angular Directive that lets you link to specific routes in your app. In a SPA(single-page application), 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.
RouterLink 是一個內置的 Angular 指令,可讓您鏈接到應用程序中的特定路由。 在 SPA(單頁應用程序)中,您可以通過顯示或隱藏與特定組件對應的顯示部分來更改用戶看到的內容,而不是前往服務器獲取新頁面。
RouterModule provides RouterLink directive in Angular. The RouterModule adds router directives and providers. RouterLink lets us link to the specific routes in our angular application.
RouterModule 在 Angular 中提供 RouterLink 指令。 RouterModule 添加路由器指令和提供程序。 RouterLink 允許我們鏈接到我們的 angular 應用程序中的特定路由。
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 locations on the page.
當應用于模板中的元素時,使該元素成為啟動導航到路線的鏈接。 導航會在頁面上的一個或多個 <router-outlet> 位置打開一個或多個路由組件。
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的Angular应用的路由指令RouterLink的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求职者嫌8000工资高要求降到2000:
- 下一篇: Redmi Note 12R Pro 手