其他分享
首页 > 其他分享> > Angular应用的路由指令RouterLink

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:

   

 

   

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

 

       

标签:RouterLink,routerLink,RouterModule,指令,router,heroes,Angular,路由
来源: https://www.cnblogs.com/diablo987987/p/13757371.html