Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何从url中删除特定参数?_Angular - Fatal编程技术网

Angular 如何从url中删除特定参数?

Angular 如何从url中删除特定参数?,angular,Angular,我有这条路线: www.test.com/evidention?procesId=12&esid=12 我只想删除此esid。有什么建议吗?在要删除的组件或服务中,您可以执行以下操作: 导出类组件或服务 { 建造师( 受保护的只读路由:ActivatedRoute, 受保护的只读路由器:路由器 ) { } deleteQueryParameterFromCurrentRoute() { 常量参数={…this.route.snapshot.queryParams}; 删除params.

我有这条路线:

www.test.com/evidention?procesId=12&esid=12

我只想删除此esid。有什么建议吗?

在要删除的组件或服务中,您可以执行以下操作:

导出类组件或服务
{
建造师(
受保护的只读路由:ActivatedRoute,
受保护的只读路由器:路由器
) { }
deleteQueryParameterFromCurrentRoute()
{
常量参数={…this.route.snapshot.queryParams};
删除params.esid;
this.router.navigate([],{queryParams:params});
}
}

PS:
[]
这里的意思是停留在同一路线上,只更改angular 7+中的
查询参数

存在错误,“activatedroutesnapshot没有提供程序”

insteated可从ActivatedRoute使用

在构造函数中使用

    private _ActivatedRoute: ActivatedRoute
通过这个,您可以更改url参数

    var snapshot = this._ActivatedRoute.snapshot;
    const params = { ...snapshot.queryParams };
    delete params.esid
    this.router.navigate([], { queryParams: params });

$location.search('myQueryStringParameter',null);这可能会有帮助,它是如何到达那里的呢?你能给我们提供一些支持代码吗?这可能只是我,但我不确定你想在这里实现什么。我有搜索表单,我添加了它作为我搜索的参数,但在最后我想删除它,因为当我重新加载页面时,我想有没有该参数的url,因为有一些基于该参数的逻辑。我将它添加到路由器中。navigate@Ali如何包含此$location.search?我试过从位置角/普通,但它不是working@None你用的是哪个角度的版本?它帮助很大。谢谢