angular - 角路线和子路线
问题描述
我有一个具有 2 个功能 useeRole1 和 uderRole2 的应用程序。在我的 userRole1 app.Routing 中,我已经声明了路由,例如 route1/subroute1 和 route1/subroute2。我有一个对应于 route1/subroute1 的页面,在这个页面中我想放置一个链接来访问 route1/subroute2。我在 html 中放什么来访问这个轮子
解决方案
有两种方法可以实现它:
使用路由器链接:
<a routerLink="['../subroute2']">SubRoute2</a>
以编程方式:
<a href="javascript:void(0)" (click)="navToSubRoute()">SubRoute2</a>
现在在您的组件中:
navToSubRoute() { this.router.navigate(['route1', 'subroute2']); }
推荐阅读
- bash - 在“then”附近抨击意外令牌
- sql - 从 Django 中的多个数据库表返回结果
- php - 我这里的代码太多了,想缩短这个
- javascript - 如何获取 JavaScript 对象的键的字符串值?
- ruby - 如何关联不同类型的角色(代理和客户)
- php - 直到 n 可被 A 或 B 整除但不能被 C 整除的数字列表
- java - 如何在 ubuntu 中使用 Intellij 的 jre
- sql - 如何更新与 SQL Server 中两个源表相比的目标表列值
- javascript - 联系表格电话号码格式Javascript
- python-3.x - 如何为高光谱图像分类制作真值或训练课程