问题描述
在我的应用程序中,我有一个类别页面,该页面具有指向各种产品列表页面的链接.如果事实证明,当您进入产品列表页面时,只有一个产品,那么它将自动导航到该产品详细信息页面.我想要的是删除历史记录中的产品列表页面路线,以便当用户在产品详细信息页面上并单击后退"按钮时,他们将转到类别页面,而不是产品列表页面,因为那样会将他们重定向回去进入详细信息页面.
In my app I have a category page that has links to a various product list pages. If it turns out that when you get to a product list page there is only one product then it automatically navigates to that product detail page. What I want is to remove the product list page route in the history so that when the user is on the product detail page and hits the back button they will go to the category page and not the product list page because that will just redirect them back to the detail page.
推荐答案
您可以使用斜角路由器replaceUrl
标志来执行此操作.有关更多详细信息,请参见api文档.此处
You can use angular routers replaceUrl
flag to do this. See api docs for more details here
this.router.navigate(['/view'], { replaceUrl: true });
这篇关于Angular 5:删除路线历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!