前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Angular应用的路由指令RouterLink

Angular应用的路由指令RouterLink

作者头像
Jerry Wang
发布2020-08-19 15:47:46
8510
发布2020-08-19 15:47:46
举报

Angular应用的路由指令RouterLinkapp Component html源代码:

代码语言:javascript
复制
<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:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档