动态更改组件但在地址栏上显示相同的 url [英] Dynamically change components but have same url displayed on address bar
问题描述
我有一个路由器插座,可以在表格、图表、列表等各种组件之间切换.
I have a router outlet that would toggle between various components like table, chart, list etc.
我要求不在地址栏上显示 url 更改.
I have a requirement to not show url change on the address bar.
假设表格路径是 http://mysite/table 并且图表是 http://mysite/chart,它应该始终显示 http://mysite 而不显示相对路径更改.
Suppose if table path is http://mysite/table and chart is http://mysite/chart, it should always show http://mysite without displaying relative path change.
我认为使用相同的 url 但想使用路由器插座是没有意义的.寻找任何想法来实现使用 angular 更改组件的想法.(即使没有路由器也可以)
I think it doesn't make sense to have same url but wants to use a router outlet. Looking for any ideas to achieve that using angular to change components. (even without router is okay)
推荐答案
使用 skipLocationChange
如此处所述 https://angular.io/api/router/NavigationExtras
Use skipLocationChange
as described here https://angular.io/api/router/NavigationExtras
这篇关于动态更改组件但在地址栏上显示相同的 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!