如何隐藏浏览器url参数angular2 routing? 我有以下问题:
http://localhost:4200/product-detail/590f643acaa7dca998c2e5bd
我需要在URL中隐藏参数并获取:
http://localhost:4200/product-detail/
路由由以下代码定义:
app.routing.ts:
export const AppRoutes: any = [
.....
{ path: "product-detail/:id", component: ProductDetailComponent }
.....
];
ProductDetail.ts
this.route.params.subscribe(params => {
this.id = params['id'];
})
答案 0 :(得分:0)
导航到所需路线时,您可以使用skipLocationChange
:
this.router.navigate(['/product-detail'], { queryParams: this.id, skipLocationChange: true});