【发布时间】:2018-10-28 16:08:23
【问题描述】:
我的动态路由可以在参数中包含斜杠或反斜杠,例如:
http://localhost:4200/dashboard/T64/27D我应该导航到路由T64/27D的页面
这是我的导航方式
this.router.navigate(['dashboard/'+this.groupListPage[0].code]);
this.groupList[0].code 包含T64/27D
实际上 Angular 将 T64 和 27D 分开为 2 个不同的页面。
这是错误:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard/T64/27D'
Error: Cannot match any routes. URL Segment: 'dashboard/T64/27D'
我如何告诉 Angular / 是参数的一部分?
【问题讨论】:
-
您可以做的是在不同的变量中获取参数的 2 部分,例如您的状态中的
dashboard/:param1/:param2',然后使用param1 + '/' + param2重新组合它。在某种程度上是一种解决方法,但它应该可以工作 -
问题是我并不总是有斜线..
标签: angular typescript url routing angular-router