How to hide angular2 browser url parameter

how to hide angular2 browser url parameter? I have the following problem:

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

I need to hide a parameter in a url and get:

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

The route is determined by the following code:

app.routing.ts:

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

      

ProductDetail.ts

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

      

+3


source to share


1 answer


When navigating your desired route, you can use skipLocationChange

:



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

0


source







All Articles