如何在 router.navigate 后更改并传递参数
how to change after router.navigate and passing paramenter
我需要将参数从 url 传递给另一个。假设有这个 url:
http://localhost:4200/dev/11
我想回家传递参数,所以 angular
中的 url 和 Ido
this.router.navigate(['/products'], { queryParams: { order: 'popular' } });
问题是 url 变成了 http://localhost:4200/products?order=popular
,但我想隐藏参数并只显示 url http://localhost:4200/products
试试这个:
this.router.navigate(['/products',{id:1}]);
或
this.router.navigate(['/products', {order: 'popular'}]);
要将参数与路由一起发送,您需要尝试这个 -
this.router.navigate(['/products', yourParmas]);
或
this.router.navigateByUrl('/products/' + yourParmas);
有关更多信息,请参阅官方文档 -
我需要将参数从 url 传递给另一个。假设有这个 url:
http://localhost:4200/dev/11
我想回家传递参数,所以 angular
中的 url 和 Idothis.router.navigate(['/products'], { queryParams: { order: 'popular' } });
问题是 url 变成了 http://localhost:4200/products?order=popular
,但我想隐藏参数并只显示 url http://localhost:4200/products
试试这个:
this.router.navigate(['/products',{id:1}]);
或
this.router.navigate(['/products', {order: 'popular'}]);
要将参数与路由一起发送,您需要尝试这个 -
this.router.navigate(['/products', yourParmas]);
或
this.router.navigateByUrl('/products/' + yourParmas);
有关更多信息,请参阅官方文档 -