简体   繁体   English

如何隐藏浏览器url参数angular2路由

[英]how to hide browser url parameter angular2 routing

how to hide browser url parameter angular2 routing?如何隐藏浏览器url参数angular2路由? I have the following problem:我有以下问题:

http://localhost:4200/product-detail/590f643acaa7dca998c2e5bd http://localhost:4200/product-detail/590f643acaa7dca998c2e5bd

I need to hide the parameter in the URL and get:我需要隐藏 URL 中的参数并获取:

http://localhost:4200/product-detail/ http://localhost:4200/product-detail/

The route is defined by the following code:路由由以下代码定义:

app.routing.ts: app.routing.ts:

 export const AppRoutes: any = [
 .....
 { path: "product-detail/:id", component: ProductDetailComponent }
 .....
 ];

ProductDetail.ts产品详情.ts

  this.route.params.subscribe(params => {
    this.id = params['id'];
  })

导航到所需路线时,您可以使用skipLocationChange

this.router.navigate(['/product-detail'], { queryParams: this.id, skipLocationChange: true});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM